BSD PTYs signal I/O-error when trying to read from a master side whose
authorChris Hanson <org/chris-hanson/cph>
Tue, 23 Nov 1993 01:23:16 +0000 (01:23 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 23 Nov 1993 01:23:16 +0000 (01:23 +0000)
slave has been closed; SYSV PTYs return EOF in same case.  Add code to
handle BSD case (this code has a race in it but seems to work OK).

v7/src/edwin/process.scm

index 528c452e66c0d3df4509b170c298be86f43f1111..98a2ab9e21e676c173a5ad7ad71239f9146ace1d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Id: process.scm,v 1.31 1993/09/10 19:12:52 cph Exp $
+;;;    $Id: process.scm,v 1.32 1993/11/23 01:23:16 cph Exp $
 ;;;
 ;;;    Copyright (c) 1991-93 Massachusetts Institute of Technology
 ;;;
@@ -277,16 +277,18 @@ Initialized from the SHELL environment variable."
   (let ((channel (process-input-channel process))
        (buffer (make-string 512)))
     (and (channel-open? channel)
-        (let ((n (channel-read channel buffer 0 512)))
-          (cond ((not n)
-                 #f)
-                ((> n 0)
-                 (output-substring process buffer n))
-                (else
+        (let ((close-input
+               (lambda ()
                  (deregister-process-input process)
                  (channel-close channel)
                  (%update-global-notification-tick)
-                 (poll-process-for-status-change process)))))))
+                 (poll-process-for-status-change process))))
+          (if (process-runnable? process)
+              (let ((n (channel-read channel buffer 0 512)))
+                (cond ((not n) #f)
+                      ((> n 0) (output-substring process buffer n))
+                      (else (close-input))))
+              (close-input))))))
 \f
 (define (process-send-eof process)
   (process-send-char process #\EOT))