Skip to content

Commit

Permalink
Merge pull request #4624 from eval-exec/exec/fix/widnows-ci
Browse files Browse the repository at this point in the history
Integration Test: do not kill gracefully on windows
  • Loading branch information
eval-exec committed Aug 29, 2024
2 parents 50b74a2 + 3a40e37 commit f9c3c70
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ use std::sync::{Arc, RwLock};
use std::thread::sleep;
use std::time::{Duration, Instant};

#[cfg(target_os = "windows")]
use windows_sys::Win32::System::Console::{GenerateConsoleCtrlEvent, CTRL_C_EVENT};

pub(crate) struct ProcessGuard {
pub name: String,
pub child: Child,
Expand Down Expand Up @@ -845,28 +842,19 @@ impl Node {
info!("accessed db done");
}

#[allow(unused_mut)]
pub fn stop_gracefully(&mut self) {
let guard = self.take_guard();
if let Some(mut guard) = guard {
if !guard.killed {
// on nix: send SIGINT to the child
// on windows: use taskkill to kill the child gracefully
Self::kill_gracefully(guard.child.id());
let _ = guard.child.wait();
guard.killed = true;
}
}
}

#[cfg(target_os = "windows")]
fn kill_gracefully(pid: u32) {
unsafe {
let ret = GenerateConsoleCtrlEvent(CTRL_C_EVENT, pid);
if ret == 0 {
let err = std::io::Error::last_os_error();
error!("GenerateConsoleCtrlEvent failed: {}", err);
} else {
info!("GenerateConsoleCtrlEvent success");
// on windows: don't kill gracefully..... fix later
#[cfg(not(target_os = "windows"))]
{
Self::kill_gracefully(guard.child.id());
let _ = guard.child.wait();
guard.killed = true;
}
}
}
}
Expand Down

0 comments on commit f9c3c70

Please sign in to comment.