mes: system*: Support redirection.
* mes/module/mes/posix.mes (system*): Support redirection.
This commit is contained in:
parent
d2cba60eb4
commit
1f1fa33eaa
|
@ -49,7 +49,16 @@
|
|||
|
||||
(define (system* file-name . args)
|
||||
(let ((pid (primitive-fork)))
|
||||
(cond ((zero? pid) (apply execlp file-name (list args)))
|
||||
(cond ((zero? pid)
|
||||
(let ((out (current-output-port))
|
||||
(err (current-error-port)))
|
||||
(when (and (> out 0)
|
||||
(not (= out 1)))
|
||||
(dup2 out 1))
|
||||
(when (and (> err 0)
|
||||
(not (= err 2)))
|
||||
(dup2 err 2))
|
||||
(exit (apply execlp file-name (list args)))))
|
||||
((= -1 pid) (error "fork failed:" file-name))
|
||||
(else (let ((pid+status (waitpid 0)))
|
||||
(cdr pid+status))))))
|
||||
|
|
Loading…
Reference in a new issue