#![cfg(unix)]
use std::process::{Command, Stdio};
use heim_process as process;
#[heim_derive::test]
async fn test_kill() {
let yes_path = match which::which("yes") {
Ok(path) => path,
Err(e) => {
eprintln!(
"Unable to find `yes` command, signals test will be skipped: {:?}",
e
);
return;
}
};
let mut child = Command::new(yes_path)
.stdout(Stdio::null())
.spawn()
.unwrap();
let process = process::get(child.id() as process::Pid).await.unwrap();
let result = process.kill().await;
assert!(result.is_ok(), "Failed to kill the process: {:?}", result);
match child.try_wait() {
Ok(..) => {
}
Err(e) => panic!("Process::signal failed to kill the test process: {:#?}", e),
}
}