changeset 22079:b7a2370ee82d

(sys_select): Always wait on interrupt_handle, so that user can break out of `accept-process-input' (for instance) by typing C-g.
author Richard M. Stallman <rms@gnu.org>
date Fri, 15 May 1998 20:55:26 +0000
parents f4099a0f3575
children f519dedee9bc
files src/w32proc.c
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32proc.c	Fri May 15 20:53:53 1998 +0000
+++ b/src/w32proc.c	Fri May 15 20:55:26 1998 +0000
@@ -987,10 +987,20 @@
    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 @@
   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 @@
 	      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 */