Skip to content

Commit

Permalink
Fix zombie ssh processes from accumulating
Browse files Browse the repository at this point in the history
  • Loading branch information
cesfahani committed Apr 3, 2024
1 parent 4bb8ef5 commit ba93ef2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gix-transport/src/client/blocking_io/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ impl client::TransportWithoutIO for SpawnProcessOnDemand {
}
}

impl Drop for SpawnProcessOnDemand {
fn drop(&mut self) {
if let Some(mut child) = self.child.take() {
// The child process (e.g. `ssh`) may still be running at this point, so kill it before joining/waiting.
// In the happy-path case, it should have already exited gracefully, but in error cases or if the user
// interrupted the operation, it will likely still be running.
child.kill().ok();
child.wait().ok();
}
}
}

struct ReadStdoutFailOnError {
recv: std::sync::mpsc::Receiver<std::io::Error>,
read: std::process::ChildStdout,
Expand Down

0 comments on commit ba93ef2

Please sign in to comment.