Skip to content

Commit

Permalink
chore: terminate child processes on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Aug 21, 2024
1 parent 4c163f4 commit f332bca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/rust/driver/src/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ impl ChildPluginProcess {
let mut s = System::new();
s.refresh_processes();
if let Some(process) = s.process(Pid::from_u32(self.child_pid as u32)) {
#[cfg(not(windows))]
process.kill();
#[cfg(windows)]
process::Command::new("taskkill.exe").arg("/PID").arg(child_pid.to_string()).arg("/F").arg("/T").output();
} else {
warn!("Child process with PID {} was not found", self.child_pid);
}
Expand Down
3 changes: 3 additions & 0 deletions drivers/rust/driver/src/plugin_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ async fn start_plugin_process(manifest: &PactPluginManifest) -> anyhow::Result<P
let mut s = System::new();
s.refresh_processes();
if let Some(process) = s.process(Pid::from_u32(child_pid)) {
#[cfg(not(windows))]
process.kill();
#[cfg(windows)]
process::Command::new("taskkill.exe").arg("/PID").arg(child_pid.to_string()).arg("/F").arg("/T").creation_flags(CREATE_NO_WINDOW.0).output();
} else {
warn!("Child process with PID {} was not found", child_pid);
}
Expand Down

0 comments on commit f332bca

Please sign in to comment.