mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
call-with-process-io should terminate if execute returns (i.e. fails)
This commit is contained in:
parent
1027b424c2
commit
28011727e4
1 changed files with 14 additions and 10 deletions
|
@ -54,19 +54,22 @@
|
|||
(else x)))
|
||||
(execvp (->string cmd) (map ->string args)))
|
||||
|
||||
(define (execute-returned cmd)
|
||||
;; we only arrive here if execute fails
|
||||
(let ((err (current-error-port)))
|
||||
(cond
|
||||
((output-port? err)
|
||||
(display "ERROR: couldn't execute: " (current-error-port))
|
||||
(write cmd (current-error-port))
|
||||
(newline (current-error-port))))
|
||||
(exit 1)))
|
||||
|
||||
(define (system cmd . args)
|
||||
(let ((pid (fork)))
|
||||
(cond
|
||||
((zero? pid)
|
||||
(let* ((res (execute cmd (cons cmd args)))
|
||||
(err (current-error-port)))
|
||||
;; we only arrive here if execute fails
|
||||
(cond
|
||||
((output-port? err)
|
||||
(display "ERROR: couldn't execute: " (current-error-port))
|
||||
(write cmd (current-error-port))
|
||||
(newline (current-error-port))))
|
||||
(exit 1)))
|
||||
(execute cmd (cons cmd args))
|
||||
(execute-returned cmd))
|
||||
(else
|
||||
(waitpid pid 0)))))
|
||||
|
||||
|
@ -98,7 +101,8 @@
|
|||
(close-file-descriptor (car in-pipe))
|
||||
(close-file-descriptor (cadr out-pipe))
|
||||
(close-file-descriptor (cadr err-pipe))
|
||||
(execute (car command-ls) command-ls))
|
||||
(execute (car command-ls) command-ls)
|
||||
(execute-returned command-ls))
|
||||
(else ;; parent
|
||||
(close-file-descriptor (car in-pipe))
|
||||
(close-file-descriptor (cadr out-pipe))
|
||||
|
|
Loading…
Add table
Reference in a new issue