Skip to content

Commit

Permalink
Merge pull request #1333 from cesfahani/fix_zombie_ssh_procs
Browse files Browse the repository at this point in the history
Fix zombie ssh processes from accumulating
  • Loading branch information
Byron committed Apr 3, 2024
2 parents 37732fb + 6118c5c commit 16dc027
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 16dc027

Please sign in to comment.