process: add test for Child::kill after Child::wait (#7163)

This commit is contained in:
Stepan Koltsov
2025-02-19 00:52:50 +03:30
committed by GitHub
parent 4380c3d821
commit 13fbdace66
+27
View File
@@ -0,0 +1,27 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi cannot run system commands
use tokio::process::Command;
#[tokio::test]
async fn kill_after_wait() {
let mut cmd;
if cfg!(windows) {
cmd = Command::new("cmd");
cmd.arg("/c");
} else {
cmd = Command::new("sh");
cmd.arg("-c");
}
let mut child = cmd.arg("exit 2").spawn().unwrap();
child.start_kill().unwrap();
child.wait().await.unwrap();
// Kill after `wait` is fine.
child.start_kill().unwrap();
child.kill().await.unwrap();
}