mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-10 22:47:33 +02:00
close stdout/err in process->foo utilities
Relying on gc can accumulate many open fd's, which is bad for code outside of chibi.
This commit is contained in:
parent
7ea15f3810
commit
d80589144d
1 changed files with 8 additions and 0 deletions
|
@ -175,6 +175,8 @@
|
||||||
(close-output-port in)
|
(close-output-port in)
|
||||||
(let ((res (port->bytevector out)))
|
(let ((res (port->bytevector out)))
|
||||||
(waitpid pid 0)
|
(waitpid pid 0)
|
||||||
|
(close-input-port out)
|
||||||
|
(close-input-port err)
|
||||||
res))))
|
res))))
|
||||||
|
|
||||||
;;> Utility to run \var{command} and return the accumulated output as
|
;;> Utility to run \var{command} and return the accumulated output as
|
||||||
|
@ -186,6 +188,8 @@
|
||||||
(close-output-port in)
|
(close-output-port in)
|
||||||
(let ((res (port->string out)))
|
(let ((res (port->string out)))
|
||||||
(waitpid pid 0)
|
(waitpid pid 0)
|
||||||
|
(close-input-port out)
|
||||||
|
(close-input-port err)
|
||||||
res))))
|
res))))
|
||||||
|
|
||||||
;;> Utility to run \var{command} and return the accumulated output as
|
;;> Utility to run \var{command} and return the accumulated output as
|
||||||
|
@ -204,6 +208,8 @@
|
||||||
(let* ((out (port->string out))
|
(let* ((out (port->string out))
|
||||||
(err (port->string err))
|
(err (port->string err))
|
||||||
(res (waitpid pid 0)))
|
(res (waitpid pid 0)))
|
||||||
|
(close-input-port out)
|
||||||
|
(close-input-port err)
|
||||||
(list out err (cadr res))))))
|
(list out err (cadr res))))))
|
||||||
|
|
||||||
;;> Utility to run \var{command} and return a list of two values:
|
;;> Utility to run \var{command} and return a list of two values:
|
||||||
|
@ -221,4 +227,6 @@
|
||||||
(close-output-port in)
|
(close-output-port in)
|
||||||
(let ((res (port->string-list out)))
|
(let ((res (port->string-list out)))
|
||||||
(waitpid pid 0)
|
(waitpid pid 0)
|
||||||
|
(close-input-port out)
|
||||||
|
(close-input-port err)
|
||||||
res))))
|
res))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue