process: make Child::kill async (#2823)

* This changes the `Child::kill` to be an async method which awaits the
  child after sending a kill signal. This avoids leaving zombie
  processes on Unix platforms if the caller forgets to await the child
  after the kill completes
* A `start_kill` method was also added on `Child` which only sends the
  kill signal to the child process. This allows for kill signals to be
  sent even outside of async contexts.
This commit is contained in:
Ivan Petkov
2020-09-08 06:03:25 +00:00
committed by GitHub
parent f4d6ed03d9
commit 7c254eca44
2 changed files with 24 additions and 15 deletions
+1 -2
View File
@@ -39,8 +39,7 @@ async fn issue_2174() {
time::delay_for(Duration::from_secs(1)).await;
// Kill the child process.
child.kill().unwrap();
let _ = child.wait().await;
child.kill().await.unwrap();
assert_err!(handle.await);
}