Adding process->output+error+status.

This commit is contained in:
Alex Shinn 2015-04-03 07:13:33 +09:00
parent 3700b86470
commit 443dd1bc3f
2 changed files with 18 additions and 14 deletions

View file

@ -111,31 +111,35 @@
(open-input-file-descriptor (car out-pipe))
(open-input-file-descriptor (car err-pipe)))))))))
(define (process->string str)
(define (process->string command)
(call-with-process-io
str
command
(lambda (pid in out err)
(close-output-port in)
(let ((res (port->string out)))
(waitpid pid 0)
res))))
(define (process->sexp str)
(call-with-input-string (process->string str) read))
(define (process->sexp command)
(call-with-input-string (process->string command) read))
(define (process->output+error str)
(define (process->output+error+status command)
(call-with-process-io
str
command
(lambda (pid in out err)
(close-output-port in)
(let ((out (port->string out))
(err (port->string err)))
(waitpid pid 0)
(list out err)))))
(let* ((out (port->string out))
(err (port->string err))
(res (waitpid pid 0)))
(list out err (cadr res))))))
(define (process->string-list str)
(define (process->output+error command)
(let ((res (process->output+error+status command)))
(list (car res) (cadr res))))
(define (process->string-list command)
(call-with-process-io
str
command
(lambda (pid in out err)
(close-output-port in)
(let ((res (port->string-list out)))

View file

@ -15,8 +15,8 @@
signal/stop signal/tty-stop signal/tty-input
signal/tty-output wait/no-hang
call-with-process-io
process->string process->sexp
process->string-list process->output+error)
process->string process->sexp process->string-list
process->output+error process->output+error+status)
(import (chibi) (chibi io) (chibi string) (chibi filesystem))
(cond-expand (threads (import (srfi 18) (srfi 33))) (else #f))
(include-shared "process")