diff --git a/Cargo.lock b/Cargo.lock index 52878592a24..23ad26be6b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2890,9 +2890,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" dependencies = [ "bytes", "fnv", diff --git a/gix-transport/src/client/blocking_io/file.rs b/gix-transport/src/client/blocking_io/file.rs index 5106e407ad3..5f5bf25b0db 100644 --- a/gix-transport/src/client/blocking_io/file.rs +++ b/gix-transport/src/client/blocking_io/file.rs @@ -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, read: std::process::ChildStdout,