Skip to content

Commit 71a9146

Browse files
committed
Test for Child::kill after wait
Forgot to submit as part of #7160
1 parent 383da87 commit 71a9146

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![warn(rust_2018_idioms)]
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi cannot run system commands
3+
4+
use tokio::process::Command;
5+
6+
#[tokio::test]
7+
async fn kill_after_wait() {
8+
let mut cmd;
9+
10+
if cfg!(windows) {
11+
cmd = Command::new("cmd");
12+
cmd.arg("/c");
13+
} else {
14+
cmd = Command::new("sh");
15+
cmd.arg("-c");
16+
}
17+
18+
let mut child = cmd.arg("exit 2").spawn().unwrap();
19+
20+
child.start_kill().unwrap();
21+
22+
child.wait().await.unwrap();
23+
24+
// Kill after `wait` is fine.
25+
child.start_kill().unwrap();
26+
child.kill().await.unwrap();
27+
child.kill().await.unwrap();
28+
child.kill().await.unwrap();
29+
}

0 commit comments

Comments
 (0)