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:
Alex Shinn 2021-03-31 09:23:21 +09:00
parent 7ea15f3810
commit d80589144d

View file

@ -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))))