Change `OS_channel_read' and `OS_channel_write' to be interruptable,
authorChris Hanson <org/chris-hanson/cph>
Thu, 21 Jun 1990 20:02:06 +0000 (20:02 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 21 Jun 1990 20:02:06 +0000 (20:02 +0000)
so that any I/O can be interrupted by the user typing ^G.  Fix minor
thinko in `OS_channel_close' that caused the console I/O channels to
be marked as closed even though they were still open.

v7/src/microcode/osio.h
v7/src/microcode/uxio.c
v7/src/microcode/uxterm.c
v7/src/microcode/uxtty.c
v7/src/microcode/version.h
v8/src/microcode/version.h

index 69fc60379310fd9e62489629e6e095ed4deccc0d..650b83ffc112575cc36eedb515b508423ffc5294 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osio.h,v 1.1 1990/06/20 19:36:26 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osio.h,v 1.2 1990/06/21 20:01:42 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -65,7 +65,6 @@ extern long EXFUN
   (OS_channel_read, (Tchannel channel, PTR buffer, size_t nbytes));
 extern long EXFUN
   (OS_channel_write, (Tchannel channel, CONST PTR buffer, size_t nbytes));
-extern int EXFUN (OS_channel_read_char_interruptably, (Tchannel channel));
 extern void EXFUN
   (OS_channel_write_string, (Tchannel channel, CONST char * string));
 extern int EXFUN (OS_channel_nonblocking_p, (Tchannel channel));
index 75f107d9b914110c2f1d2d0074f4140c642a83da..3bbe061533da28e45fc3ac8fa956389b06ed423f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.c,v 1.1 1990/06/20 19:37:14 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.c,v 1.2 1990/06/21 20:01:48 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -62,7 +62,7 @@ DEFUN_VOID (OS_channel_close_all)
 {
   Tchannel channel;
   for (channel = 0; (channel < OS_channel_table_size); channel += 1)
-    if ((CHANNEL_OPEN_P (channel)) && (! (CHANNEL_INTERNAL (channel))))
+    if (CHANNEL_OPEN_P (channel))
       OS_channel_close (channel);
 }
 
@@ -90,8 +90,10 @@ void
 DEFUN (OS_channel_close, (channel), Tchannel channel)
 {
   if (! (CHANNEL_INTERNAL (channel)))
-    STD_VOID_SYSTEM_CALL ("close", (UX_close (CHANNEL_DESCRIPTOR (channel))));
-  MARK_CHANNEL_CLOSED (channel);
+    {
+      STD_VOID_SYSTEM_CALL ("close", (UX_close (CHANNEL_DESCRIPTOR (channel))));
+      MARK_CHANNEL_CLOSED (channel);
+    }
 }
 
 void
@@ -139,16 +141,17 @@ DEFUN (OS_channel_read, (channel, buffer, nbytes),
     return (0);
   while (1)
     {
-      long scr = (UX_read ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes));
+      long scr;
+      INTERRUPTABLE_EXTENT
+       (scr, (UX_read ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes)));
       if (scr < 0)
        {
 #ifdef ERRNO_NONBLOCK
          if (errno == ERRNO_NONBLOCK)
            return (-1);
 #endif
-         if (errno == EINTR)
-           continue;
-         error_system_call (errno, "read");
+         UX_prim_check_errno ("read");
+         continue;
        }
       if (scr > nbytes)
        error_external_return ();
@@ -170,16 +173,17 @@ DEFUN (OS_channel_write, (channel, buffer, nbytes),
     return (0);
   while (1)
     {
-      long scr = (UX_write ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes));
+      long scr;
+      INTERRUPTABLE_EXTENT
+       (scr, (UX_write ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes)));
       if (scr < 0)
        {
 #ifdef ERRNO_NONBLOCK
          if (errno == ERRNO_NONBLOCK)
            return (-1);
 #endif
-         if (errno == EINTR)
-           continue;
-         error_system_call (errno, "write");
+         UX_prim_check_errno ("write");
+         continue;
        }
       if (scr > nbytes)
        error_external_return ();
@@ -203,29 +207,6 @@ DEFUN (OS_channel_write_dump_file, (channel, buffer, nbytes),
   return ((scr < 0) ? 0 : scr);
 }
 
-int
-DEFUN (OS_channel_read_char_interruptably, (channel), Tchannel channel)
-{
-  unsigned char c;
-  int nread;
-  while (1)
-    {
-      INTERRUPTABLE_EXTENT
-       (nread, (UX_read ((CHANNEL_DESCRIPTOR (channel)), ((PTR) (&c)), 1)));
-      if (nread >= 0)
-       break;
-#ifdef ERRNO_NONBLOCK
-         if (errno == ERRNO_NONBLOCK)
-           {
-             nread = 0;
-             break;
-           }
-#endif
-      UX_prim_check_errno ("read");
-    }
-  return ((nread == 1) ? c : (-1));
-}
-
 void
 DEFUN (OS_channel_write_string, (channel, string),
        Tchannel channel AND
index ffe7637ae27cf260ec4b58fd158a0d0834defec7..4808a4e1aa3341976ba95ccea3693f09fa85a566 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.1 1990/06/20 19:37:38 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.2 1990/06/21 20:01:53 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -99,7 +99,11 @@ DEFUN (OS_terminal_read_char, (channel), Tchannel channel)
        return (c);
       }
   }
-  return (OS_channel_read_char_interruptably (channel));
+  {
+    unsigned char c;
+    long nread = (OS_channel_read (channel, (&c), 1));
+    return ((nread == 1) ? c : (-1));
+  }
 }
 \f
 int
index 98563b554722ad1576142f6e9385672808642e0e..8e763507aee5cdc07e722dc2082fc96ef0d75441 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtty.c,v 1.1 1990/06/20 19:38:04 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtty.c,v 1.2 1990/06/21 20:01:58 cph Exp $
 
 Copyright (c) 1990 Massachusetts Institute of Technology
 
@@ -54,7 +54,6 @@ DEFUN_VOID (OS_tty_input_channel)
 static unsigned char
 DEFUN (tty_read_char, (immediate), int immediate)
 {
-  int c;
   if ((OS_channel_type (input_channel)) == channel_type_terminal)
     {
       transaction_begin ();
@@ -63,20 +62,23 @@ DEFUN (tty_read_char, (immediate), int immediate)
        OS_terminal_nonbuffered (input_channel);
       else
        OS_terminal_buffered (input_channel);
-      c = (OS_terminal_read_char (input_channel));
-      if (c == (-1))
-       termination_eof ();
-      transaction_commit ();
+      {
+       int c = (OS_terminal_read_char (input_channel));
+       if (c == (-1))
+         termination_eof ();
+       transaction_commit ();
+       return ((unsigned char) c);
+      }
     }
   else
     {
-      c = (OS_channel_read_char_interruptably (input_channel));
-      if (c == (-1))
+      unsigned char c;
+      if ((OS_channel_read (input_channel, (&c), 1)) != 1)
        termination_eof ();
       if ((OS_channel_type (input_channel)) == channel_type_file)
        OS_tty_write_char (c);
+      return (c);
     }
-  return ((unsigned char) c);
 }
 
 unsigned char
index be74b9f10d0dd9a14fde058ad561aafb3a7e5ab6..fdfffc05dc8aab26b435dc90a32bb60e4a0b8bfa 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.33 1990/06/20 20:00:58 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.34 1990/06/21 20:02:06 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     33
+#define SUBVERSION     34
 #endif
 
 #ifndef UCODE_TABLES_FILENAME
index a165963b5b785366fe5c3fead4e919ced87f8a31..1a35c590543a9bda12adf364c664ff80ad561a81 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.33 1990/06/20 20:00:58 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.34 1990/06/21 20:02:06 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     33
+#define SUBVERSION     34
 #endif
 
 #ifndef UCODE_TABLES_FILENAME