diff src/process.c @ 648:70b112526394

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Mon, 18 May 1992 08:14:41 +0000
parents 40b255f55df3
children 39f0e62a8511
line wrap: on
line diff
--- a/src/process.c	Mon May 18 08:13:37 1992 +0000
+++ b/src/process.c	Mon May 18 08:14:41 1992 +0000
@@ -65,41 +65,12 @@
 #include <bsdtty.h>
 #endif
 
-#ifdef HPUX
-#undef TIOCGPGRP
-#endif
-
 #ifdef IRIS
 #include <sys/sysmacros.h>	/* for "minor" */
 #endif /* not IRIS */
 
 #include "systime.h"
-
-#if defined (HPUX) && defined (HAVE_PTYS)
-#include <sys/ptyio.h>
-#endif
-
-#ifdef AIX
-#include <sys/pty.h>
-#include <unistd.h>
-#endif
-
-#ifdef SYSV_PTYS
-#include <sys/tty.h>
-#ifdef titan
-#include <sys/ttyhw.h>
-#include <sys/stream.h>
-#endif
-#include <sys/pty.h>
-#endif
-
-#ifdef XENIX
-#undef TIOCGETC  /* Avoid confusing some conditionals that test this.  */
-#endif
-
-#ifdef BROKEN_TIOCGETC
-#undef TIOCGETC
-#endif
+#include "systerm.h"
 
 #include "lisp.h"
 #include "window.h"
@@ -1690,10 +1661,6 @@
       EMACS_ADD_TIME (end_time, end_time, timeout);
     }
 
-  /* Turn off periodic alarms (in case they are in use)
-     because the select emulator uses alarms.  */
-  stop_polling ();
-
   while (1)
     {
       /* If calling from keyboard input, do not quit
@@ -1752,6 +1719,13 @@
       if (!read_kbd)
 	FD_CLR (0, &Available);
 
+      /* If screen size has changed or the window is newly mapped,
+	 redisplay now, before we start to wait.  There is a race
+	 condition here; if a SIGIO arrives between now and the select
+	 and indicates that a screen is trashed, we lose.  */
+      if (screen_garbaged)
+	redisplay_preserve_echo_area ();
+
       if (read_kbd && detect_input_pending ())
 	nfds = 0;
       else
@@ -1765,7 +1739,7 @@
       /*  If we woke up due to SIGWINCH, actually change size now.  */
       do_pending_window_change ();
 
-      if (time_limit && nfds == 0)	/* timeout elapsed */
+      if (time_limit && nfds == 0) /* timeout elapsed */
 	break;
       if (nfds < 0)
 	{
@@ -1787,7 +1761,7 @@
 		 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
 		 in m-ibmrt-aix.h), and here we just ignore the select error.
 		 Cleanup occurs c/o status_notify after SIGCLD. */
-	      FD_ZERO (&Available);          /* Cannot depend on values returned */
+	      FD_ZERO (&Available); /* Cannot depend on values returned */
 #else
 	      abort ();
 #endif
@@ -1815,8 +1789,8 @@
 	 but select says there is input.  */
 
       /*
-      if (read_kbd && interrupt_input && (Available & fileno (stdin)))
-      */
+	if (read_kbd && interrupt_input && (Available & fileno (stdin)))
+	*/
       if (read_kbd && interrupt_input && (FD_ISSET (fileno (stdin), &Available)))
 	kill (0, SIGIO);
 #endif
@@ -1839,11 +1813,6 @@
       if (read_kbd)
 	do_pending_window_change ();
 
-      /* If screen size has changed, redisplay now
-	 for either sit-for or keyboard input.  */
-      if (read_kbd && screen_garbaged)
-	redisplay_preserve_echo_area ();
-
       /* Check for data from a process or a command channel */
       for (channel = FIRST_PROC_DESC; channel < MAXDESC; channel++)
 	{
@@ -1880,7 +1849,7 @@
 		    }
 		  continue;
 		}
-#endif /* vipc */
+#endif				/* vipc */
 
 	      /* Read data from the process, starting with our
 		 buffered-ahead character if we have one.  */
@@ -1914,9 +1883,9 @@
 		 subprocess termination and SIGCHLD.  */
 	      else if (nread == 0 && !NETCONN_P (proc))
 		;
-#endif /* O_NDELAY */
-#endif /* O_NONBLOCK */
-#endif /* EWOULDBLOCK */
+#endif				/* O_NDELAY */
+#endif				/* O_NONBLOCK */
+#endif				/* EWOULDBLOCK */
 #ifdef HAVE_PTYS
 	      /* On some OSs with ptys, when the process on one end of
 		 a pty exits, the other end gets an error reading with
@@ -1927,9 +1896,9 @@
 		 get a SIGCHLD). */
 	      else if (nread == -1 && errno == EIO)
 		;
-#endif /* HAVE_PTYS */
-/* If we can detect process termination, don't consider the process
-   gone just because its pipe is closed.  */
+#endif				/* HAVE_PTYS */
+	      /* If we can detect process termination, don't consider the process
+		 gone just because its pipe is closed.  */
 #ifdef SIGCHLD
 	      else if (nread == 0 && !NETCONN_P (proc))
 		;
@@ -1946,11 +1915,18 @@
 		      = Fcons (Qexit, Fcons (make_number (256), Qnil));
 		}
 	    }
-	} /* end for each file descriptor */
-    } /* end while exit conditions not met */
-
-  /* Resume periodic signals to poll for input, if necessary.  */
-  start_polling ();
+	}			/* end for each file descriptor */
+    }				/* end while exit conditions not met */
+
+  /* If calling from keyboard input, do not quit
+     since we want to return C-g as an input character.
+     Otherwise, do pending quit if requested.  */
+  if (read_kbd >= 0)
+    {
+      /* Prevent input_pending from remaining set if we quit.  */
+      clear_input_pending ();
+      QUIT;
+    }
 
   return got_some_input;
 }