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. */
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'. */
/* 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 */
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
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. */
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