mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Adding process->output+error+status.
This commit is contained in:
parent
3700b86470
commit
443dd1bc3f
2 changed files with 18 additions and 14 deletions
|
@ -111,31 +111,35 @@
|
||||||
(open-input-file-descriptor (car out-pipe))
|
(open-input-file-descriptor (car out-pipe))
|
||||||
(open-input-file-descriptor (car err-pipe)))))))))
|
(open-input-file-descriptor (car err-pipe)))))))))
|
||||||
|
|
||||||
(define (process->string str)
|
(define (process->string command)
|
||||||
(call-with-process-io
|
(call-with-process-io
|
||||||
str
|
command
|
||||||
(lambda (pid in out err)
|
(lambda (pid in out err)
|
||||||
(close-output-port in)
|
(close-output-port in)
|
||||||
(let ((res (port->string out)))
|
(let ((res (port->string out)))
|
||||||
(waitpid pid 0)
|
(waitpid pid 0)
|
||||||
res))))
|
res))))
|
||||||
|
|
||||||
(define (process->sexp str)
|
(define (process->sexp command)
|
||||||
(call-with-input-string (process->string str) read))
|
(call-with-input-string (process->string command) read))
|
||||||
|
|
||||||
(define (process->output+error str)
|
(define (process->output+error+status command)
|
||||||
(call-with-process-io
|
(call-with-process-io
|
||||||
str
|
command
|
||||||
(lambda (pid in out err)
|
(lambda (pid in out err)
|
||||||
(close-output-port in)
|
(close-output-port in)
|
||||||
(let ((out (port->string out))
|
(let* ((out (port->string out))
|
||||||
(err (port->string err)))
|
(err (port->string err))
|
||||||
(waitpid pid 0)
|
(res (waitpid pid 0)))
|
||||||
(list out err)))))
|
(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
|
(call-with-process-io
|
||||||
str
|
command
|
||||||
(lambda (pid in out err)
|
(lambda (pid in out err)
|
||||||
(close-output-port in)
|
(close-output-port in)
|
||||||
(let ((res (port->string-list out)))
|
(let ((res (port->string-list out)))
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
signal/stop signal/tty-stop signal/tty-input
|
signal/stop signal/tty-stop signal/tty-input
|
||||||
signal/tty-output wait/no-hang
|
signal/tty-output wait/no-hang
|
||||||
call-with-process-io
|
call-with-process-io
|
||||||
process->string process->sexp
|
process->string process->sexp process->string-list
|
||||||
process->string-list process->output+error)
|
process->output+error process->output+error+status)
|
||||||
(import (chibi) (chibi io) (chibi string) (chibi filesystem))
|
(import (chibi) (chibi io) (chibi string) (chibi filesystem))
|
||||||
(cond-expand (threads (import (srfi 18) (srfi 33))) (else #f))
|
(cond-expand (threads (import (srfi 18) (srfi 33))) (else #f))
|
||||||
(include-shared "process")
|
(include-shared "process")
|
||||||
|
|
Loading…
Add table
Reference in a new issue