comparison src/w32proc.c @ 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 b1c3fe58dbbe
children e509b80a17a2
comparison
equal deleted inserted replaced
22078:f4099a0f3575 22079:b7a2370ee82d
985 For simplicity, we detect the death of child processes here and 985 For simplicity, we detect the death of child processes here and
986 synchronously call the SIGCHLD handler. Since it is possible for 986 synchronously call the SIGCHLD handler. Since it is possible for
987 children to be created without a corresponding pipe handle from which 987 children to be created without a corresponding pipe handle from which
988 to read output, we wait separately on the process handles as well as 988 to read output, we wait separately on the process handles as well as
989 the char_avail events for each process pipe. We only call 989 the char_avail events for each process pipe. We only call
990 wait/reap_process when the process actually terminates. */ 990 wait/reap_process when the process actually terminates.
991
992 To reduce the number of places in which Emacs can be hung such that
993 C-g is not able to interrupt it, we always wait on interrupt_handle
994 (which is signalled by the input thread when C-g is detected). If we
995 detect that we were woken up by C-g, we return -1 with errno set to
996 EINTR as on Unix. */
991 997
992 /* From ntterm.c */ 998 /* From ntterm.c */
993 extern HANDLE keyboard_handle; 999 extern HANDLE keyboard_handle;
1000
1001 /* From w32xfns.c */
1002 extern HANDLE interrupt_handle;
1003
994 /* From process.c */ 1004 /* From process.c */
995 extern int proc_buffered_char[]; 1005 extern int proc_buffered_char[];
996 1006
997 int 1007 int
998 sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 1008 sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
1023 } 1033 }
1024 1034
1025 orfds = *rfds; 1035 orfds = *rfds;
1026 FD_ZERO (rfds); 1036 FD_ZERO (rfds);
1027 nr = 0; 1037 nr = 0;
1038
1039 /* Always wait on interrupt_handle, to detect C-g (quit). */
1040 wait_hnd[0] = interrupt_handle;
1041 fdindex[0] = -1;
1028 1042
1029 /* Build a list of pipe handles to wait on. */ 1043 /* Build a list of pipe handles to wait on. */
1030 nh = 0; 1044 nh = 1;
1031 for (i = 0; i < nfds; i++) 1045 for (i = 0; i < nfds; i++)
1032 if (FD_ISSET (i, &orfds)) 1046 if (FD_ISSET (i, &orfds))
1033 { 1047 {
1034 if (i == 0) 1048 if (i == 0)
1035 { 1049 {
1210 dead_child = cp; 1224 dead_child = cp;
1211 sig_handlers[SIGCHLD] (SIGCHLD); 1225 sig_handlers[SIGCHLD] (SIGCHLD);
1212 dead_child = NULL; 1226 dead_child = NULL;
1213 } 1227 }
1214 } 1228 }
1229 else if (fdindex[active] == -1)
1230 {
1231 /* Quit (C-g) was detected. */
1232 errno = EINTR;
1233 return -1;
1234 }
1215 else if (fdindex[active] == 0) 1235 else if (fdindex[active] == 0)
1216 { 1236 {
1217 /* Keyboard input available */ 1237 /* Keyboard input available */
1218 FD_SET (0, rfds); 1238 FD_SET (0, rfds);
1219 nr++; 1239 nr++;