changeset 4682:c4d471244116

(keyboard_descriptor): New variable. (wait_reading_process_input, init_keyboard): Use it. Also call change_input_fd. (change_keyboard_wait_descriptor): New function.
author Richard M. Stallman <rms@gnu.org>
date Wed, 08 Sep 1993 17:53:11 +0000
parents 6945d02dd725
children 6a5197116086
files src/process.c
diffstat 1 files changed, 36 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/process.c	Wed Sep 08 16:55:53 1993 +0000
+++ b/src/process.c	Wed Sep 08 17:53:11 1993 +0000
@@ -73,6 +73,7 @@
 #include "commands.h"
 #include "frame.h"
 
+Lisp_Object Qprocessp;
 Lisp_Object Qrun, Qstop, Qsignal, Qopen, Qclosed;
 /* Qexit is declared and initialized in eval.c.  */
 
@@ -150,7 +151,7 @@
 
 /* t means use pty, nil means use a pipe,
    maybe other values to come.  */
-Lisp_Object Vprocess_connection_type;
+static Lisp_Object Vprocess_connection_type;
 
 #ifdef SKTPAIR
 #ifndef HAVE_SOCKETS
@@ -159,10 +160,10 @@
 #endif /* SKTPAIR */
 
 /* Number of events of change of status of a process.  */
-int process_tick;
+static int process_tick;
 
 /* Number of events for which the user or sentinel has been notified.  */
-int update_tick;
+static int update_tick;
 
 #ifdef FD_SET
 /* We could get this from param.h, but better not to depend on finding that.
@@ -187,19 +188,19 @@
 
 /* Mask of bits indicating the descriptors that we wait for input on */
 
-SELECT_TYPE input_wait_mask;
-
-int delete_exited_processes;
+static SELECT_TYPE input_wait_mask;
+
+/* Descriptor to use for keyboard input.  */
+static int keyboard_descriptor;
+
+/* Nonzero means delete a process right away if it exits.  */
+static int delete_exited_processes;
 
 /* Indexed by descriptor, gives the process (if any) for that descriptor */
-Lisp_Object chan_process[MAXDESC];
+static Lisp_Object chan_process[MAXDESC];
 
 /* Alist of elements (NAME . PROCESS) */
-Lisp_Object Vprocess_alist;
-
-Lisp_Object Qprocessp;
-
-Lisp_Object get_process ();
+static Lisp_Object Vprocess_alist;
 
 /* Buffered-ahead input char from process, indexed by channel.
    -1 means empty (no char is buffered).
@@ -207,7 +208,9 @@
    output from the process is to read at least one char.
    Always -1 on systems that support FIONREAD.  */
 
-int proc_buffered_char[MAXDESC];
+static int proc_buffered_char[MAXDESC];
+
+static Lisp_Object get_process ();
 
 /* Compute the Lisp form of the process status, p->status, from
    the numeric status that was returned by `wait'.  */
@@ -1753,7 +1756,7 @@
 	 but that led to lossage handling selection_request events:
 	 within one, we would start to handle another.  */
       if (! XINT (read_kbd))
-	FD_CLR (0, &Available);
+	FD_CLR (keyboard_descriptor, &Available);
 
       /* If frame size has changed or the window is newly mapped,
 	 redisplay now, before we start to wait.  There is a race
@@ -1816,7 +1819,8 @@
 	    error("select error: %s", sys_errlist[xerrno]);
 	}
 #if defined(sun) && !defined(USG5_4)
-      else if (nfds > 0 && FD_ISSET (0, &Available) && interrupt_input)
+      else if (nfds > 0 && FD_ISSET (keyboard_descriptor, &Available)
+	       && interrupt_input)
 	/* System sometimes fails to deliver SIGIO.
 
 	   David J. Mackenzie says that Emacs doesn't compile under
@@ -1851,7 +1855,8 @@
 	 In that case, there really is no input and no SIGIO,
 	 but select says there is input.  */
 
-      if (XINT (read_kbd) && interrupt_input && (FD_ISSET (fileno (stdin), &Available)))
+      if (XINT (read_kbd) && interrupt_input
+	  && (FD_ISSET (keyboard_descriptor, &Available)))
 	kill (0, SIGIO);
 #endif
 
@@ -2930,7 +2935,10 @@
 #endif
 
   FD_ZERO (&input_wait_mask);
-  FD_SET (0, &input_wait_mask);
+
+  keyboard_descriptor = 0;
+  FD_SET (keyboard_descriptor, &input_wait_mask);
+
   Vprocess_alist = Qnil;
   for (i = 0; i < MAXDESC; i++)
     {
@@ -2939,6 +2947,17 @@
     }
 }
 
+/* From now on, assume keyboard input comes from descriptor DESC.  */
+
+void
+change_keyboard_wait_descriptor (desc)
+     int desc;
+{
+  FD_CLR (keyboard_descriptor, &input_wait_mask);
+  keyboard_descriptor = desc;
+  FD_SET (keyboard_descriptor, &input_wait_mask);
+}
+
 syms_of_process ()
 {
 #ifdef HAVE_SOCKETS