1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 04:15:36 +02:00

popen: 'open-process' returns unbuffered ports.

* module/ice-9/popen.scm (open-process)[unbuffered, fdes-pair]: New
procedures.
Use them.  Return unbuffered ports.
* test-suite/tests/popen.test ("open-pipe*"): New test prefix.
This commit is contained in:
Ludovic Courtès 2020-06-19 20:56:38 +02:00
parent 52baa45d40
commit c7f76d94da
2 changed files with 43 additions and 5 deletions

View file

@ -196,6 +196,29 @@ exec 2>~a; read REPLY"
(close-pipe port)
result))))))
(with-test-prefix "open-pipe*"
(pass-if-equal "OPEN_BOTH"
'(0 (good!))
;; This test ensures that the ports that underlie the read/write
;; port are unbuffered. If they were buffered, the child process
;; would wait in 'read' forever.
(let ((pipe (open-pipe* OPEN_BOTH "guile" "-c"
(object->string
'(begin
(setvbuf (current-output-port) 'line)
(write '(hello!))
(newline)
(let ((greeting (read)))
(write '(good!))))))))
(setvbuf pipe 'line)
(let ((return (read pipe)))
(write '(hi!) pipe)
(newline pipe)
(let ((last (read pipe)))
(list (close-pipe pipe) last))))))
;;
;; close-pipe
;;