mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-16 09:27:33 +02:00
call-with-process-io auto-non-blocks the fds
This commit is contained in:
parent
a8eb496962
commit
902a37b259
2 changed files with 12 additions and 1 deletions
|
@ -64,6 +64,14 @@
|
|||
(waitpid pid 0)))))
|
||||
|
||||
(define (call-with-process-io command proc)
|
||||
(define (set-non-blocking! fd)
|
||||
(cond-expand
|
||||
(threads
|
||||
(set-file-descriptor-status!
|
||||
fd
|
||||
(bitwise-ior open/non-block (get-file-descriptor-status fd))))
|
||||
(else
|
||||
#f)))
|
||||
(let ((command-ls (if (string? command) (string-split command) command))
|
||||
(in-pipe (open-pipe))
|
||||
(out-pipe (open-pipe))
|
||||
|
@ -88,6 +96,9 @@
|
|||
(close-file-descriptor (car in-pipe))
|
||||
(close-file-descriptor (cadr out-pipe))
|
||||
(close-file-descriptor (cadr err-pipe))
|
||||
(set-non-blocking! (cadr in-pipe))
|
||||
(set-non-blocking! (car out-pipe))
|
||||
(set-non-blocking! (car err-pipe))
|
||||
(proc pid
|
||||
(open-output-file-descriptor (cadr in-pipe))
|
||||
(open-input-file-descriptor (car out-pipe))
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
call-with-process-io
|
||||
process->string process->string-list process->output+error)
|
||||
(import (chibi) (chibi io) (chibi string) (chibi filesystem))
|
||||
(cond-expand (threads (import (srfi 18))) (else #f))
|
||||
(cond-expand (threads (import (srfi 18) (srfi 33))) (else #f))
|
||||
(include-shared "process")
|
||||
(include "process.scm"))
|
||||
|
|
Loading…
Add table
Reference in a new issue