From 83ca1b35ec2f9d348d49945624b5740cf313edaf Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 9 May 2026 21:57:39 +0200 Subject: [PATCH] josh-proxy shutdown: try longer and reduce slack --- src/josh.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/josh.rs b/src/josh.rs index 20e2d71..63c3aa0 100644 --- a/src/josh.rs +++ b/src/josh.rs @@ -153,15 +153,26 @@ impl Drop for RunningJoshProxy { .output() .expect("failed to SIGINT josh-proxy"); // Sadly there is no "wait with timeout"... so we just give it some time to finish. - std::thread::sleep(Duration::from_millis(100)); - // Now hopefully it is gone. - if self - .process - .try_wait() - .expect("failed to wait for josh-proxy") - .is_some() - { - return; + // We try every 10ms until 1s passed. + for i in 0..100 { + if i == 10 { + // If we're still here after 100ms, try a bit harder. + Command::new("kill") + .args(["-s", "TERM", &self.process.id().to_string()]) + .output() + .expect("failed to SIGTERM josh-proxy"); + } + // Give josh some time to react. + std::thread::sleep(Duration::from_millis(10)); + // Now hopefully it is gone. + if self + .process + .try_wait() + .expect("failed to wait for josh-proxy") + .is_some() + { + return; + } } } // If that didn't work (or we're not on Unix), kill it hard.