From 86143765b73911455910d7d034810c97e05d2919 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Fri, 15 May 1998 20:55:26 +0000 Subject: [PATCH] (sys_select): Always wait on interrupt_handle, so that user can break out of `accept-process-input' (for instance) by typing C-g. --- src/w32proc.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/w32proc.c b/src/w32proc.c index a416403b74b..ccb47ccc895 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -987,10 +987,20 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) children to be created without a corresponding pipe handle from which to read output, we wait separately on the process handles as well as the char_avail events for each process pipe. We only call - wait/reap_process when the process actually terminates. */ + wait/reap_process when the process actually terminates. + + To reduce the number of places in which Emacs can be hung such that + C-g is not able to interrupt it, we always wait on interrupt_handle + (which is signalled by the input thread when C-g is detected). If we + detect that we were woken up by C-g, we return -1 with errno set to + EINTR as on Unix. */ /* From ntterm.c */ extern HANDLE keyboard_handle; + +/* From w32xfns.c */ +extern HANDLE interrupt_handle; + /* From process.c */ extern int proc_buffered_char[]; @@ -1025,9 +1035,13 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, orfds = *rfds; FD_ZERO (rfds); nr = 0; + + /* Always wait on interrupt_handle, to detect C-g (quit). */ + wait_hnd[0] = interrupt_handle; + fdindex[0] = -1; /* Build a list of pipe handles to wait on. */ - nh = 0; + nh = 1; for (i = 0; i < nfds; i++) if (FD_ISSET (i, &orfds)) { @@ -1212,6 +1226,12 @@ count_children: dead_child = NULL; } } + else if (fdindex[active] == -1) + { + /* Quit (C-g) was detected. */ + errno = EINTR; + return -1; + } else if (fdindex[active] == 0) { /* Keyboard input available */ -- 2.39.2