Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/josh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading