summaryrefslogtreecommitdiffstats
path: root/tokio/tests/process_issue_42.rs
diff options
context:
space:
mode:
authorIvan Petkov <ivanppetkov@gmail.com>2020-09-06 20:30:40 -0700
committerGitHub <noreply@github.com>2020-09-07 03:30:40 +0000
commit842d5565bdd4310cd96386a8ffa9949b24c5856f (patch)
tree33ce4fd24247ad7b4e65a1341961580f4baf1af9 /tokio/tests/process_issue_42.rs
parentd74eabc7d795afa8ca2cd9170977d47131e12ee0 (diff)
process: add Child::{wait,try_wait} (#2796)
* add Child::try_wait to mirror the std API * replace Future impl on Child with `.wait()` method to bring our APIs closer to those in std and it allow us to internally fuse the future so that repeated calls to `wait` result in the same value (similar to std) without forcing the caller to fuse the outer future * Also change `Child::id` to return an Option result to avoid allowing the caller to accidentally use the pid on Unix systems after the child has been reaped * Also remove deprecated Child methods
Diffstat (limited to 'tokio/tests/process_issue_42.rs')
-rw-r--r--tokio/tests/process_issue_42.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/tokio/tests/process_issue_42.rs b/tokio/tests/process_issue_42.rs
index aa70af3b..569c122e 100644
--- a/tokio/tests/process_issue_42.rs
+++ b/tokio/tests/process_issue_42.rs
@@ -18,14 +18,16 @@ async fn issue_42() {
let join_handles = (0..10usize).map(|_| {
task::spawn(async {
let processes = (0..10usize).map(|i| {
- Command::new("echo")
+ let mut child = Command::new("echo")
.arg(format!("I am spawned process #{}", i))
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.kill_on_drop(true)
.spawn()
- .unwrap()
+ .unwrap();
+
+ async move { child.wait().await }
});
join_all(processes).await;