From 612950b23a519b3d12d7b56150e2feea3fcc307a Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 1 Apr 2022 16:31:35 +0200 Subject: [PATCH] fix zombie subprocesses by waiting on them Also bump to 0.2.1. --- Cargo.toml | 2 +- src/main.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c44b6ec..71cdb6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opal" -version = "0.2.0" +version = "0.2.1" edition = "2021" license = "GPL-3.0-or-later" diff --git a/src/main.rs b/src/main.rs index 6d9e78b..52c156f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -210,9 +210,9 @@ fn handle_client(tls_stream: &mut ssl::SslStream, cgi_config: &C // Get appropriate response from either Opal or the CGI process. match get_response(&request[..read_bytes], cgi_config, &tls_stream) { - Ok((url, child)) => { + Ok((url, mut child)) => { let mut buffer = vec![0u8; 4096]; - let mut stdout = child.stdout.expect("child process stdout not available"); + let mut stdout = child.stdout.take().expect("child process stdout not available"); let mut num_sent = 0; loop { match stdout.read(&mut buffer) { @@ -228,6 +228,7 @@ fn handle_client(tls_stream: &mut ssl::SslStream, cgi_config: &C } } info!("\"{}\" → replied {} bytes", url, num_sent); + child.wait().expect("child process can't be waited for"); let mut stderr = child.stderr.expect("child process' stderr not available"); let mut errors = vec![]; match stderr.read_to_end(&mut errors) {