handle-subprocess-status-change: Do not close i/o channels!
authorMatt Birkholz <matt@birkholz.chandler.az.us>
Wed, 9 Oct 2013 23:20:58 +0000 (16:20 -0700)
committerMatt Birkholz <matt@birkholz.chandler.az.us>
Wed, 9 Oct 2013 23:20:58 +0000 (16:20 -0700)
On Unix subprocess i/o channels need only be closed by subprocess-
delete or the GC.  Otherwise subprocess termination can close them
before their readers/writers can drain them, resulting in truncated
output.

src/runtime/process.scm

index bc7b81c4e0ed2ce5e74183dd607e76338fa417c8..6432ae936600e55315b3d8ec773f4a077c509bbd 100644 (file)
@@ -277,12 +277,13 @@ USA.
   (let ((latest-tick (subprocess-global-status-tick)))
     (if (not (eq? latest-tick last-global-tick))
        (begin
-         (for-each (lambda (process)
-                     (if (memq (subprocess-status process) '(EXITED SIGNALLED))
-                         (close-subprocess-i/o process)))
-                   (subprocess-list))
          (signal-subprocess-status-change)
-         (set! last-global-tick latest-tick)))))
+         (set! last-global-tick latest-tick))))
+  (if (eq? 'NT microcode-id/operating-system)
+      (for-each (lambda (process)
+                 (if (memq (subprocess-status process) '(EXITED SIGNALLED))
+                     (close-subprocess-i/o process)))
+               (subprocess-list))))
 
 (define-integrable subprocess-job-control-available?
   (ucode-primitive os-job-control? 0))