diff options
Diffstat (limited to 'scsh-process.scm')
-rw-r--r-- | scsh-process.scm | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/scsh-process.scm b/scsh-process.scm index d815e6c..e60fb67 100644 --- a/scsh-process.scm +++ b/scsh-process.scm @@ -90,23 +90,24 @@ (hash-table-ref/default *scsh-pending-processes* pid-or-process #f) pid-or-process))) - (or (and p (scsh-process-exit-status p)) + (if (and p (scsh-process-exit-status p)) + (values (scsh-process-pid p) + (scsh-process-ok? p) + (scsh-process-exit-status p)) (handle-exceptions exn (if (and p (scsh-process-exit-status p)) ; Signal might've occurred - (values (scsh-process-exit-status p) + (values (scsh-process-pid p) (scsh-process-ok? p) - (scsh-process-pid p)) + (scsh-process-exit-status p)) (abort exn)) (receive (pid ok? status) (posix-process-wait (and p (scsh-process-pid p))) - (cond - ((zero? pid) (values #f #f #f)) - (else + (unless (zero? pid) (when p (scsh-process-exit-status-set! p status) (scsh-process-ok?-set! p ok?)) - (remove-scsh-pending-process! pid) - (values status ok? pid))))))))) + (remove-scsh-pending-process! pid)) + (values pid ok? status))))))) (set-signal-handler! signal/chld @@ -213,9 +214,9 @@ (conns (map (lambda (from-fd temp-file) (list from-fd (port->fileno temp-file))) fds temp-files))) - (receive (code ok? pid) + (receive (pid ok? status) (process-wait (fork/pipe+ conns thunk)) - (apply values code temp-files)))) + (apply values status temp-files)))) (define (run/port* thunk) (receive (in out) @@ -297,7 +298,10 @@ (define-syntax run (syntax-rules () - ((_ ?epf ...) (process-wait (& ?epf ...))))) + ((_ ?epf ...) + (receive (pid ok? status) + (process-wait (& ?epf ...)) + (values status ok? pid))))) ;; Perhaps this should really be a procedure? (define-syntax setup-redirection |