From d80589144d70f2f246656a888d142214d53ed909 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 31 Mar 2021 09:23:21 +0900 Subject: [PATCH] close stdout/err in process->foo utilities Relying on gc can accumulate many open fd's, which is bad for code outside of chibi. --- lib/chibi/process.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/chibi/process.scm b/lib/chibi/process.scm index 0f8f5284..31c45afe 100644 --- a/lib/chibi/process.scm +++ b/lib/chibi/process.scm @@ -175,6 +175,8 @@ (close-output-port in) (let ((res (port->bytevector out))) (waitpid pid 0) + (close-input-port out) + (close-input-port err) res)))) ;;> Utility to run \var{command} and return the accumulated output as @@ -186,6 +188,8 @@ (close-output-port in) (let ((res (port->string out))) (waitpid pid 0) + (close-input-port out) + (close-input-port err) res)))) ;;> Utility to run \var{command} and return the accumulated output as @@ -204,6 +208,8 @@ (let* ((out (port->string out)) (err (port->string err)) (res (waitpid pid 0))) + (close-input-port out) + (close-input-port err) (list out err (cadr res)))))) ;;> Utility to run \var{command} and return a list of two values: @@ -221,4 +227,6 @@ (close-output-port in) (let ((res (port->string-list out))) (waitpid pid 0) + (close-input-port out) + (close-input-port err) res))))