Skip to content

Commit ba93ef2

Browse files
committed
Fix zombie ssh processes from accumulating
1 parent 4bb8ef5 commit ba93ef2

File tree

1 file changed

+12
-0
lines changed
  • gix-transport/src/client/blocking_io

1 file changed

+12
-0
lines changed

gix-transport/src/client/blocking_io/file.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ impl client::TransportWithoutIO for SpawnProcessOnDemand {
126126
}
127127
}
128128

129+
impl Drop for SpawnProcessOnDemand {
130+
fn drop(&mut self) {
131+
if let Some(mut child) = self.child.take() {
132+
// The child process (e.g. `ssh`) may still be running at this point, so kill it before joining/waiting.
133+
// In the happy-path case, it should have already exited gracefully, but in error cases or if the user
134+
// interrupted the operation, it will likely still be running.
135+
child.kill().ok();
136+
child.wait().ok();
137+
}
138+
}
139+
}
140+
129141
struct ReadStdoutFailOnError {
130142
recv: std::sync::mpsc::Receiver<std::io::Error>,
131143
read: std::process::ChildStdout,

0 commit comments

Comments
 (0)