aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorEli Zaretskii2021-01-23 12:51:57 +0200
committerEli Zaretskii2021-01-23 12:51:57 +0200
commit8d8e1dfd05fd79859e8206de0e89329b0d862ce1 (patch)
treed139a9e29be2dc615cc00ed3936a007578207371 /src/process.c
parentcc98d0bf5225c281f91152aa838c4cb093df52e9 (diff)
downloademacs-8d8e1dfd05fd79859e8206de0e89329b0d862ce1.tar.gz
emacs-8d8e1dfd05fd79859e8206de0e89329b0d862ce1.zip
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.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/process.c b/src/process.c
index 57105982c15..697d9b0b19b 100644
--- a/src/process.c
+++ b/src/process.c
@@ -290,7 +290,10 @@ static int child_signal_read_fd = -1;
290 status changes. */ 290 status changes. */
291static int child_signal_write_fd = -1; 291static int child_signal_write_fd = -1;
292static void child_signal_init (void); 292static void child_signal_init (void);
293#ifndef WINDOWSNT
294/* FIXME: This is never used, on all platforms. */
293static void child_signal_read (int, void *); 295static void child_signal_read (int, void *);
296#endif
294static void child_signal_notify (void); 297static void child_signal_notify (void);
295 298
296/* Indexed by descriptor, gives the process (if any) for that descriptor. */ 299/* Indexed by descriptor, gives the process (if any) for that descriptor. */
@@ -7148,8 +7151,18 @@ process has been transmitted to the serial port. */)
7148 have the same process ID. 7151 have the same process ID.
7149 7152
7150 To avoid a deadlock when receiving SIGCHLD while 7153 To avoid a deadlock when receiving SIGCHLD while
7151 `wait_reading_process_output' is in `pselect', the SIGCHLD handler 7154 'wait_reading_process_output' is in 'pselect', the SIGCHLD handler
7152 will notify the `pselect' using a pipe. */ 7155 will notify the `pselect' using a self-pipe. The deadlock could
7156 occur if SIGCHLD is delivered outside of the 'pselect' call, in
7157 which case 'pselect' will not be interrupted by the signal, and
7158 will therefore wait on the process's output descriptor for the
7159 output that will never come.
7160
7161 WINDOWSNT doesn't need this facility because its 'pselect'
7162 emulation (see 'sys_select' in w32proc.c) waits on a subprocess
7163 handle, which becomes signaled when the process exits, and also
7164 because that emulation delays the delivery of the simulated SIGCHLD
7165 until all the output from the subprocess has been consumed. */
7153 7166
7154/* Set up `child_signal_read_fd' and `child_signal_write_fd'. */ 7167/* Set up `child_signal_read_fd' and `child_signal_write_fd'. */
7155 7168
@@ -7159,6 +7172,7 @@ child_signal_init (void)
7159 /* Either both are initialized, or both are uninitialized. */ 7172 /* Either both are initialized, or both are uninitialized. */
7160 eassert ((child_signal_read_fd < 0) == (child_signal_write_fd < 0)); 7173 eassert ((child_signal_read_fd < 0) == (child_signal_write_fd < 0));
7161 7174
7175#ifndef WINDOWSNT
7162 if (0 <= child_signal_read_fd) 7176 if (0 <= child_signal_read_fd)
7163 return; /* already done */ 7177 return; /* already done */
7164 7178
@@ -7185,8 +7199,10 @@ child_signal_init (void)
7185 fd_callback_info[fds[0]].flags &= ~KEYBOARD_FD; 7199 fd_callback_info[fds[0]].flags &= ~KEYBOARD_FD;
7186 child_signal_read_fd = fds[0]; 7200 child_signal_read_fd = fds[0];
7187 child_signal_write_fd = fds[1]; 7201 child_signal_write_fd = fds[1];
7202#endif /* !WINDOWSNT */
7188} 7203}
7189 7204
7205#ifndef WINDOWSNT
7190/* Consume a process status change. */ 7206/* Consume a process status change. */
7191 7207
7192static void 7208static void
@@ -7198,6 +7214,7 @@ child_signal_read (int fd, void *data)
7198 if (emacs_read (fd, &dummy, 1) < 0) 7214 if (emacs_read (fd, &dummy, 1) < 0)
7199 emacs_perror ("reading from child signal FD"); 7215 emacs_perror ("reading from child signal FD");
7200} 7216}
7217#endif /* !WINDOWSNT */
7201 7218
7202/* Notify `wait_reading_process_output' of a process status 7219/* Notify `wait_reading_process_output' of a process status
7203 change. */ 7220 change. */
@@ -7205,11 +7222,13 @@ child_signal_read (int fd, void *data)
7205static void 7222static void
7206child_signal_notify (void) 7223child_signal_notify (void)
7207{ 7224{
7225#ifndef WINDOWSNT
7208 int fd = child_signal_write_fd; 7226 int fd = child_signal_write_fd;
7209 eassert (0 <= fd); 7227 eassert (0 <= fd);
7210 char dummy = 0; 7228 char dummy = 0;
7211 if (emacs_write (fd, &dummy, 1) != 1) 7229 if (emacs_write (fd, &dummy, 1) != 1)
7212 emacs_perror ("writing to child signal FD"); 7230 emacs_perror ("writing to child signal FD");
7231#endif
7213} 7232}
7214 7233
7215/* LIB_CHILD_HANDLER is a SIGCHLD handler that Emacs calls while doing 7234/* LIB_CHILD_HANDLER is a SIGCHLD handler that Emacs calls while doing