* New primitives `channel-register', `channel-unregister', and
authorChris Hanson <org/chris-hanson/cph>
Mon, 11 Mar 1991 23:43:28 +0000 (23:43 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 11 Mar 1991 23:43:28 +0000 (23:43 +0000)
  `channel-registered?' allow registering of a set of channels that is
  to be watched for input at certain points.

* New primitive `channel-select-then-read' is like `channel-read', but
  returns #T if the given channel has no input but some other
  registered channel has some input instead.

* Primitive `x-display-process-events' now returns #T if there are no
  input events but a registered channel has some input.

* Primitive `make-subprocess' now permits the "inheritance" of
  Scheme's control terminal even when there is none.

* New primitive `process-status-sync-all' synchronizes the status of
  all subprocesses: it returns #T iff some status has changed since
  the last call to this primitive.

v7/src/microcode/osio.h
v7/src/microcode/osproc.h
v7/src/microcode/prosio.c
v7/src/microcode/prosproc.c
v7/src/microcode/uxio.c
v7/src/microcode/uxio.h
v7/src/microcode/uxproc.c
v7/src/microcode/version.h
v7/src/microcode/x11base.c
v8/src/microcode/version.h

index 4e0450956ce547fe75d1dbdc75d9e7d8214f53c5..2ec48f8b3ac993d60a9c328b57b5aef9a0e6b0e9 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osio.h,v 1.6 1991/03/01 00:54:54 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osio.h,v 1.7 1991/03/11 23:42:31 cph Exp $
 
-Copyright (c) 1990 Massachusetts Institute of Technology
+Copyright (c) 1990-91 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -77,4 +77,11 @@ extern int EXFUN (OS_channel_nonblocking_p, (Tchannel channel));
 extern void EXFUN (OS_channel_nonblocking, (Tchannel channel));
 extern void EXFUN (OS_channel_blocking, (Tchannel channel));
 
+extern unsigned int OS_channels_registered;
+extern int EXFUN (OS_channels_registered_p, (void));
+extern void EXFUN (OS_channel_register, (Tchannel channel));
+extern void EXFUN (OS_channel_unregister, (Tchannel channel));
+extern long EXFUN
+  (OS_channel_select_then_read, (Tchannel channel, PTR buffer, size_t nbytes));
+
 #endif /* SCM_OSIO_H */
index f8b33fcf3185a03edddc1dd216e5750728f1801f..cded37efa248c3370281245c6b15e9147734f1bc 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osproc.h,v 1.3 1991/03/09 21:10:45 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osproc.h,v 1.4 1991/03/11 23:42:38 cph Exp $
 
 Copyright (c) 1990-91 Massachusetts Institute of Technology
 
@@ -107,6 +107,7 @@ extern int EXFUN (OS_process_foregroundable_p, (Tprocess process));
 extern pid_t EXFUN (OS_process_id, (Tprocess process));
 extern enum process_jc_status EXFUN (OS_process_jc_status, (Tprocess process));
 extern int EXFUN (OS_process_status_sync, (Tprocess process));
+extern int EXFUN (OS_process_status_sync_all, (void));
 extern enum process_status EXFUN (OS_process_status, (Tprocess process));
 extern unsigned short EXFUN (OS_process_reason, (Tprocess process));
 
index f44ea4be84c3a586c5aa497c3f01c46f8f634551..0db50638d35ed96c8e55a9cf653f74ae58ee82b3 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosio.c,v 1.4 1991/03/01 00:55:30 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosio.c,v 1.5 1991/03/11 23:42:45 cph Exp $
 
 Copyright (c) 1987-91 Massachusetts Institute of Technology
 
@@ -191,7 +191,7 @@ DEFINE_PRIMITIVE ("CHANNEL-BLOCKING", Prim_channel_blocking, 1, 1,
   OS_channel_blocking (arg_channel (1));
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
-
+\f
 DEFINE_PRIMITIVE ("MAKE-PIPE", Prim_make_pipe, 0, 0,
   "Return a cons of two channels, the reader and writer of a pipe.")
 {
@@ -206,3 +206,52 @@ DEFINE_PRIMITIVE ("MAKE-PIPE", Prim_make_pipe, 0, 0,
     PRIMITIVE_RETURN (result);
   }
 }
+
+DEFINE_PRIMITIVE ("CHANNEL-REGISTERED?", Prim_channel_registered_p, 1, 1,
+  "Return #F iff CHANNEL is registered for selection.")
+{
+  PRIMITIVE_HEADER (1);
+  PRIMITIVE_RETURN
+    (BOOLEAN_TO_OBJECT (OS_channel_registered_p (arg_channel (1))));
+}
+
+DEFINE_PRIMITIVE ("CHANNEL-REGISTER", Prim_channel_register, 1, 1,
+  "Register CHANNEL for selection.")
+{
+  PRIMITIVE_HEADER (1);
+  OS_channel_register (arg_channel (1));
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
+
+DEFINE_PRIMITIVE ("CHANNEL-UNREGISTER", Prim_channel_unregister, 1, 1,
+  "Unregister CHANNEL for selection.")
+{
+  PRIMITIVE_HEADER (1);
+  OS_channel_unregister (arg_channel (1));
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
+
+DEFINE_PRIMITIVE ("CHANNEL-SELECT-THEN-READ", Prim_channel_select_then_read, 4, 4,
+  "Like CHANNEL-READ, but also watches registered input channels.\n\
+If there is no input on CHANNEL, but there is input on some other registered\n\
+channel, this procedure returns #T.")
+{
+  PRIMITIVE_HEADER (4);
+  CHECK_ARG (2, STRING_P);
+  {
+    SCHEME_OBJECT buffer = (ARG_REF (2));
+    long length = (STRING_LENGTH (buffer));
+    long end = (arg_index_integer (4, (length + 1)));
+    long start = (arg_index_integer (3, (end + 1)));
+    long nread =
+      (OS_channel_select_then_read ((arg_channel (1)),
+                                   (STRING_LOC (buffer, start)),
+                                   (end - start)));
+    PRIMITIVE_RETURN
+      ((nread == -2)
+       ? SHARP_T
+       : (nread < 0)
+       ? SHARP_F
+       : (long_to_integer (nread)));
+  }
+}
index f9d919a231145e5863ed44e87872e96f2ad98968..61d816240fd86025cafd0cb4512c53809ba4110e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosproc.c,v 1.6 1991/03/09 21:10:50 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosproc.c,v 1.7 1991/03/11 23:42:52 cph Exp $
 
 Copyright (c) 1990-91 Massachusetts Institute of Technology
 
@@ -113,17 +113,9 @@ Seventh arg STDERR is the error channel for the subprocess.\n\
     if ((ARG_REF (4)) == SHARP_F)
       ctty_type = process_ctty_type_none;
     else if ((ARG_REF (4)) == (LONG_TO_FIXNUM (-1)))
-      {
-       if (scheme_jc_status == process_jc_status_no_ctty)
-         error_bad_range_arg (4);
-       ctty_type = process_ctty_type_inherit_bg;
-      }
+      ctty_type = process_ctty_type_inherit_bg;
     else if ((ARG_REF (4)) == (LONG_TO_FIXNUM (-2)))
-      {
-       if (scheme_jc_status == process_jc_status_no_ctty)
-         error_bad_range_arg (4);
-       ctty_type = process_ctty_type_inherit_fg;
-      }
+      ctty_type = process_ctty_type_inherit_fg;
     else
       {
        ctty_type = process_ctty_type_explicit;
@@ -235,7 +227,7 @@ DEFINE_PRIMITIVE ("PROCESS-TABLE", Prim_process_table, 0, 0,
     }
   }
 }
-\f
+
 DEFINE_PRIMITIVE ("PROCESS-ID", Prim_process_id, 1, 1, 
   "Return the process ID of process PROCESS-NUMBER.")
 {
@@ -266,7 +258,7 @@ DEFINE_PRIMITIVE ("PROCESS-JOB-CONTROL-STATUS", Prim_process_jc_status, 1, 1,
       PRIMITIVE_RETURN (UNSPECIFIC);
     }
 }
-
+\f
 DEFINE_PRIMITIVE ("PROCESS-STATUS-SYNC", Prim_process_status_sync, 1, 1,
   "Synchronize the status of process PROCESS-NUMBER.\n\
 Return #F if it was previously synchronized, #T if not.")
@@ -276,6 +268,12 @@ Return #F if it was previously synchronized, #T if not.")
     (BOOLEAN_TO_OBJECT (OS_process_status_sync (arg_process (1))));
 }
 
+DEFINE_PRIMITIVE ("PROCESS-STATUS-SYNC-ALL", Prim_process_status_sync_all, 0, 0, 0)
+{
+  PRIMITIVE_HEADER (0);
+  PRIMITIVE_RETURN (BOOLEAN_TO_OBJECT (OS_process_status_sync_all ()));
+}
+
 DEFINE_PRIMITIVE ("PROCESS-STATUS", Prim_process_status, 1, 1,
   "Return the status of process PROCESS-NUMBER, a nonnegative integer:\n\
   0 = running; 1 = stopped; 2 = exited; 3 = signalled.\n\
index 50ef39c83167aef862feb05a1b939f29b0e892bd..b550e9bbd27235d00b2000e3eee16938eacdccc4 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.c,v 1.9 1991/03/01 00:56:07 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.c,v 1.10 1991/03/11 23:43:02 cph Exp $
 
-Copyright (c) 1990-1 Massachusetts Institute of Technology
+Copyright (c) 1990-91 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -38,6 +38,23 @@ MIT in each case. */
 size_t OS_channel_table_size;
 struct channel * channel_table;
 
+#ifdef FD_SET
+#define SELECT_TYPE fd_set
+#else
+#define SELECT_TYPE int
+#define FD_SETSIZE ((sizeof (int)) * CHAR_BIT)
+#define FD_SET(n, p) ((*(p)) |= (1 << (n)))
+#define FD_CLR(n, p) ((*(p)) &= ~(1 << (n)))
+#define FD_ISSET(n, p) (((*(p)) & (1 << (n))) != 0)
+#define FD_ZERO(p) ((*(p)) = 0)
+#endif
+
+unsigned int OS_channels_registered;
+static SELECT_TYPE input_descriptors;
+#ifdef HAVE_SELECT
+static struct timeval zero_timeout;
+#endif
+
 static void
 DEFUN_VOID (UX_channel_close_all)
 {
@@ -65,6 +82,12 @@ DEFUN_VOID (UX_initialize_channels)
       MARK_CHANNEL_CLOSED (channel);
   }
   add_reload_cleanup (UX_channel_close_all);
+  FD_ZERO (&input_descriptors);
+  OS_channels_registered = 0;
+#ifdef HAVE_SELECT
+  (zero_timeout . tv_sec) = 0;
+  (zero_timeout . tv_usec) = 0;
+#endif
 }
 
 void
@@ -100,6 +123,7 @@ DEFUN (OS_channel_close, (channel), Tchannel channel)
 {
   if (! (CHANNEL_INTERNAL (channel)))
     {
+      OS_channel_unregister (channel);
       STD_VOID_SYSTEM_CALL
        (syscall_close, (UX_close (CHANNEL_DESCRIPTOR (channel))));
       MARK_CHANNEL_CLOSED (channel);
@@ -111,6 +135,7 @@ DEFUN (OS_channel_close_noerror, (channel), Tchannel channel)
 {
   if (! (CHANNEL_INTERNAL (channel)))
     {
+      OS_channel_unregister (channel);
       UX_close (CHANNEL_DESCRIPTOR (channel));
       MARK_CHANNEL_CLOSED (channel);
     }
@@ -298,3 +323,67 @@ DEFUN (OS_channel_blocking, (channel), Tchannel channel)
 }
 
 #endif /* FCNTL_NONBLOCK */
+\f
+int
+DEFUN (OS_channel_registered_p, (channel), Tchannel channel)
+{
+  return (CHANNEL_REGISTERED (channel));
+}
+
+void
+DEFUN (OS_channel_register, (channel), Tchannel channel)
+{
+#ifdef HAVE_SELECT
+  if (! (CHANNEL_REGISTERED (channel)))
+    {
+      FD_SET ((CHANNEL_DESCRIPTOR (channel)), (&input_descriptors));
+      OS_channels_registered += 1;
+      (CHANNEL_REGISTERED (channel)) = 1;
+    }
+#else
+  error_unimplemented_primitive ();
+#endif
+}
+
+void
+DEFUN (OS_channel_unregister, (channel), Tchannel channel)
+{
+  if (CHANNEL_REGISTERED (channel))
+    {
+      FD_CLR ((CHANNEL_DESCRIPTOR (channel)), (&input_descriptors));
+      OS_channels_registered -= 1;
+      (CHANNEL_REGISTERED (channel)) = 0;
+    }
+}
+
+int
+DEFUN (UX_select_input, (fd, blockp), int fd AND int blockp)
+{
+#ifdef HAVE_SELECT
+  int nfds;
+  SELECT_TYPE readable = input_descriptors;
+  FD_SET (fd, (&readable));
+  STD_UINT_SYSTEM_CALL
+    (syscall_select,
+     nfds,
+     (select (FD_SETSIZE, (&readable), 0, 0, (blockp ? 0 : (&zero_timeout)))));
+  return ((nfds > 0) && (! (FD_ISSET (fd, (&readable)))));
+#else
+  return (0);
+#endif
+}
+
+long
+DEFUN (OS_channel_select_then_read, (channel, buffer, nbytes),
+       Tchannel channel AND
+       PTR buffer AND
+       size_t nbytes)
+{
+#ifdef HAVE_SELECT
+  if ((OS_channels_registered > ((CHANNEL_REGISTERED (channel)) ? 1 : 0))
+      && (UX_select_input ((CHANNEL_DESCRIPTOR (channel)),
+                          (CHANNEL_NONBLOCKING (channel)))))
+    return (-2);
+#endif
+  return (OS_channel_read (channel, buffer, nbytes));
+}
index 30ced2bae540860d75aa53717398f6591f752e03..18affb12ea0539895d95cea202eadc40de327169 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.h,v 1.1 1990/06/20 19:37:20 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.h,v 1.2 1991/03/11 23:43:07 cph Exp $
 
-Copyright (c) 1990 Massachusetts Institute of Technology
+Copyright (c) 1990-91 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -43,6 +43,7 @@ struct channel
   enum channel_type type;
   unsigned int internal : 1;
   unsigned int nonblocking : 1;
+  unsigned int registered : 1;
 };
 
 #define MARK_CHANNEL_CLOSED(channel) ((CHANNEL_DESCRIPTOR (channel)) = (-1))
@@ -53,6 +54,7 @@ struct channel
 #define CHANNEL_INTERNAL(channel) ((channel_table [(channel)]) . internal)
 #define CHANNEL_NONBLOCKING(channel)                                   \
   ((channel_table [(channel)]) . nonblocking)
+#define CHANNEL_REGISTERED(channel) ((channel_table [(channel)]) . registered)
 
 #define MAKE_CHANNEL(descriptor, type, receiver)                       \
 {                                                                      \
@@ -61,6 +63,7 @@ struct channel
   (CHANNEL_TYPE (MAKE_CHANNEL_temp)) = (type);                         \
   (CHANNEL_INTERNAL (MAKE_CHANNEL_temp)) = 0;                          \
   (CHANNEL_NONBLOCKING (MAKE_CHANNEL_temp)) = 0;                       \
+  (CHANNEL_REGISTERED (MAKE_CHANNEL_temp)) = 0;                                \
   receiver (MAKE_CHANNEL_temp);                                                \
 }
 
index 8938e70e0c9aa4a28ded816040041c0063bc2d46..53b71b159c42d0e07590ba0773f28164b0adca41 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxproc.c,v 1.8 1991/03/09 21:10:57 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxproc.c,v 1.9 1991/03/11 23:43:12 cph Exp $
 
 Copyright (c) 1990-91 Massachusetts Institute of Technology
 
@@ -63,6 +63,7 @@ static int scheme_ctty_fd;
 static Tprocess foreground_child_process;
 
 static long process_tick;
+static long sync_tick;
 
 #define NEW_RAW_STATUS(process, status, reason)                                \
 {                                                                      \
@@ -142,7 +143,11 @@ DEFUN_VOID (block_sigchld)
   transaction_record_action (tat_always, release_sigchld, 0);
 }
 
-#endif /* HAVE_SYSV3_SIGNALS */
+#else /* not HAVE_SYSV3_SIGNALS */
+
+#define block_sigchld()
+
+#endif /* not HAVE_SYSV3_SIGNALS */
 
 #define block_jc_signals block_sigchld
 #define grab_signal_mask()
@@ -177,6 +182,7 @@ DEFUN_VOID (UX_initialize_processes)
   subprocess_death_hook = subprocess_death;
   stop_signal_hook = stop_signal_handler;
   process_tick = 0;
+  sync_tick = 0;
 }
 
 void
@@ -267,8 +273,7 @@ DEFUN (OS_make_subprocess,
   transaction_begin ();
   child = (process_allocate ());
 
-  /* Flush streams so that i/o won't be duplicated after the fork */
-  fflush (stdin);
+  /* Flush streams so that output won't be duplicated after the fork.  */
   fflush (stdout);
   fflush (stderr);
 
@@ -298,6 +303,7 @@ DEFUN (OS_make_subprocess,
       transaction_commit ();
       return (child);
     }
+\f
   /* In the child process -- if any errors occur, just exit. */
   /* Don't do `transaction_commit ()' here.  Because we used `vfork'
      to spawn the child, the side-effects that are performed by
@@ -353,7 +359,7 @@ DEFUN (OS_make_subprocess,
              err_fd = fd;
          }
       }
-
+\f
     /* Install the new standard I/O channels. */
     if ((in_fd >= 0) && (in_fd != STDIN_FILENO))
       {
@@ -478,8 +484,20 @@ DEFUN (OS_process_status_sync, (process), Tprocess process)
   block_sigchld ();
   {
     int result = ((PROCESS_TICK (process)) != (PROCESS_SYNC_TICK (process)));
-    if (result)
-      PROCESS_STATUS_SYNC (process);
+    if (result) PROCESS_STATUS_SYNC (process);
+    transaction_commit ();
+    return (result);
+  }
+}
+
+int
+DEFUN_VOID (OS_process_status_sync_all)
+{
+  transaction_begin ();
+  block_sigchld ();
+  {
+    int result = (process_tick != sync_tick);
+    if (result) sync_tick = process_tick;
     transaction_commit ();
     return (result);
   }
@@ -617,7 +635,15 @@ DEFUN (process_wait, (process), Tprocess process)
 #endif /* not HAVE_POSIX_SIGNALS */
 }
 \f
-static Tprocess EXFUN (find_process, (pid_t pid));
+static Tprocess
+DEFUN (find_process, (pid), pid_t pid)
+{
+  Tprocess process;
+  for (process = 0; (process < OS_process_table_size); process += 1)
+    if ((PROCESS_ID (process)) == pid)
+      return (process);
+  return (NO_PROCESS);
+}
 
 static void
 DEFUN (subprocess_death, (pid, status), pid_t pid AND wait_status_t * status)
@@ -643,16 +669,6 @@ DEFUN (subprocess_death, (pid, status), pid_t pid AND wait_status_t * status)
     }
 }
 
-static Tprocess
-DEFUN (find_process, (pid), pid_t pid)
-{
-  Tprocess process;
-  for (process = 0; (process < OS_process_table_size); process += 1)
-    if ((PROCESS_ID (process)) == pid)
-      return (process);
-  return (NO_PROCESS);
-}
-
 static void
 DEFUN (stop_signal_handler, (signo), int signo)
 {
index b0276ed42f51c42fff0d827de53a046795b8a2fc..dda3e2a28fa96dfde28827d03ea61608ccef73f0 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.66 1991/03/09 21:11:10 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.67 1991/03/11 23:43:21 cph Exp $
 
 Copyright (c) 1988-91 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     66
+#define SUBVERSION     67
 #endif
index 56d2b41cc63e9f17ec39570fb20793dad050f0bc..08b2f686b3c0d245d4ab6cbc7e0244ead55a6412 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.15 1990/10/02 22:52:26 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.16 1991/03/11 23:43:28 cph Exp $
 
-Copyright (c) 1989, 1990 Massachusetts Institute of Technology
+Copyright (c) 1989-91 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -699,6 +699,9 @@ DEFUN (x_event_to_object, (event), XEvent * event)
    entry that reads events -- or else that all other event readers
    cooperate with this strategy.  */
 
+extern unsigned int OS_channels_registered;
+extern int EXFUN (UX_select_input, (int fd, int blockp));
+
 static SCHEME_OBJECT
 DEFUN (xd_process_events, (xd, time_limit_p, time_limit),
        struct xdisplay * xd AND
@@ -713,18 +716,29 @@ DEFUN (xd_process_events, (xd, time_limit_p, time_limit),
     {
       extern unsigned long EXFUN (OS_real_time_clock, (void));
       XEvent event;
-      if (time_limit_p)
+      if (time_limit_p || (OS_channels_registered > 0))
        {
-         if (events_queued == 0)
+         if (events_queued > 0)
+           events_queued -= 1;
+         else
            while (1)
              {
                events_queued = (XEventsQueued (display, QueuedAfterReading));
                if (events_queued > 0)
-                 break;
-               if ((OS_real_time_clock ()) >= time_limit)
+                 {
+                   events_queued -= 1;
+                   break;
+                 }
+               if (time_limit_p && ((OS_real_time_clock ()) >= time_limit))
                  return (SHARP_F);
+               if (UX_select_input ((ConnectionNumber (display)),
+                                    (!time_limit_p)))
+                 /* No input is available from the display, but some
+                    other registered input channel has input.  Return a
+                    special value immediately so that input can be
+                    processed.  */
+                 return (SHARP_T);
              }
-         events_queued -= 1;
        }
       XNextEvent (display, (&event));
       if ((event . type) == KeymapNotify)
@@ -746,7 +760,7 @@ DEFUN (xd_process_events, (xd, time_limit_p, time_limit),
       }
     }
 }
-
+\f
 static void
 DEFUN_VOID (initialize_once)
 {
@@ -757,7 +771,7 @@ DEFUN_VOID (initialize_once)
   add_reload_cleanup (x_close_all_displays);
   initialization_done = 1;
 }
-\f
+
 DEFINE_PRIMITIVE ("X-DEBUG", Prim_x_debug, 1, 1, 0)
 {
   PRIMITIVE_HEADER (1);
index 99debf036cc1973fdbda6c1870af8caa0290a789..15b63b0b3c9eb58b4aa6554d798929e3472bf65b 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.66 1991/03/09 21:11:10 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.67 1991/03/11 23:43:21 cph Exp $
 
 Copyright (c) 1988-91 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     66
+#define SUBVERSION     67
 #endif