emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8d8e1df: Clean up the recently added self-pipe mechanism for WIND


From: Eli Zaretskii
Subject: master 8d8e1df: Clean up the recently added self-pipe mechanism for WINDOWSNT
Date: Sat, 23 Jan 2021 05:53:01 -0500 (EST)

branch: master
commit 8d8e1dfd05fd79859e8206de0e89329b0d862ce1
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Clean up the recently added self-pipe mechanism for WINDOWSNT
    
    * src/process.c (child_signal_init, child_signal_read)
    (child_signal_notify): #ifdef away on WINDOWSNT.
---
 src/process.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/process.c b/src/process.c
index 5710598..697d9b0 100644
--- a/src/process.c
+++ b/src/process.c
@@ -290,7 +290,10 @@ static int child_signal_read_fd = -1;
    status changes.  */
 static int child_signal_write_fd = -1;
 static void child_signal_init (void);
+#ifndef WINDOWSNT
+/* FIXME: This is never used, on all platforms.  */
 static void child_signal_read (int, void *);
+#endif
 static void child_signal_notify (void);
 
 /* Indexed by descriptor, gives the process (if any) for that descriptor.  */
@@ -7148,8 +7151,18 @@ process has been transmitted to the serial port.  */)
    have the same process ID.
 
    To avoid a deadlock when receiving SIGCHLD while
-   `wait_reading_process_output' is in `pselect', the SIGCHLD handler
-   will notify the `pselect' using a pipe.  */
+   'wait_reading_process_output' is in 'pselect', the SIGCHLD handler
+   will notify the `pselect' using a self-pipe.  The deadlock could
+   occur if SIGCHLD is delivered outside of the 'pselect' call, in
+   which case 'pselect' will not be interrupted by the signal, and
+   will therefore wait on the process's output descriptor for the
+   output that will never come.
+
+   WINDOWSNT doesn't need this facility because its 'pselect'
+   emulation (see 'sys_select' in w32proc.c) waits on a subprocess
+   handle, which becomes signaled when the process exits, and also
+   because that emulation delays the delivery of the simulated SIGCHLD
+   until all the output from the subprocess has been consumed.  */
 
 /* Set up `child_signal_read_fd' and `child_signal_write_fd'.  */
 
@@ -7159,6 +7172,7 @@ child_signal_init (void)
   /* Either both are initialized, or both are uninitialized.  */
   eassert ((child_signal_read_fd < 0) == (child_signal_write_fd < 0));
 
+#ifndef WINDOWSNT
   if (0 <= child_signal_read_fd)
     return; /* already done */
 
@@ -7185,8 +7199,10 @@ child_signal_init (void)
   fd_callback_info[fds[0]].flags &= ~KEYBOARD_FD;
   child_signal_read_fd = fds[0];
   child_signal_write_fd = fds[1];
+#endif /* !WINDOWSNT */
 }
 
+#ifndef WINDOWSNT
 /* Consume a process status change.  */
 
 static void
@@ -7198,6 +7214,7 @@ child_signal_read (int fd, void *data)
   if (emacs_read (fd, &dummy, 1) < 0)
     emacs_perror ("reading from child signal FD");
 }
+#endif /* !WINDOWSNT */
 
 /* Notify `wait_reading_process_output' of a process status
    change.  */
@@ -7205,11 +7222,13 @@ child_signal_read (int fd, void *data)
 static void
 child_signal_notify (void)
 {
+#ifndef WINDOWSNT
   int fd = child_signal_write_fd;
   eassert (0 <= fd);
   char dummy = 0;
   if (emacs_write (fd, &dummy, 1) != 1)
     emacs_perror ("writing to child signal FD");
+#endif
 }
 
 /* LIB_CHILD_HANDLER is a SIGCHLD handler that Emacs calls while doing



reply via email to

[Prev in Thread] Current Thread [Next in Thread]