Adding a system? variant of system which returns #t iff the command completes successfully.

Also allowing a list as the first argument to both.
This commit is contained in:
Alex Shinn 2015-04-24 14:10:13 +09:00
parent db16fc693c
commit 74ed34b4a3
2 changed files with 8 additions and 3 deletions

View file

@ -68,11 +68,16 @@
(let ((pid (fork)))
(cond
((zero? pid)
(execute cmd (cons cmd args))
(execute-returned cmd))
(let ((cmd ((if (pair? cmd) append cons) cmd args)))
(execute (car cmd) cmd)
(execute-returned cmd)))
(else
(waitpid pid 0)))))
(define (system? cmd . args)
(let ((res (apply system cmd args)))
(and (pair? res) (zero? (cadr res)))))
(define (call-with-process-io command proc)
(define (set-non-blocking! fd)
(cond-expand

View file

@ -1,6 +1,6 @@
(define-library (chibi process)
(export exit sleep alarm %fork fork kill execute waitpid system
(export exit sleep alarm %fork fork kill execute waitpid system system?
process-command-line process-running?
set-signal-action! make-signal-set
signal-set? signal-set-contains?