Skip to content

Commit

Permalink
Test for Child::kill after wait
Browse files Browse the repository at this point in the history
Forgot to submit as part of #7160
  • Loading branch information
stepancheg committed Feb 17, 2025
1 parent 383da87 commit c941553
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tokio/tests/process_kill_after_wait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![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().unwrap();
child.kill().unwrap();
child.kill().unwrap();
}

0 comments on commit c941553

Please sign in to comment.