wip: starter and reaper works

This commit is contained in:
2023-11-21 18:18:26 +11:00
parent 6ba6bc6cda
commit ce9df6364f
4 changed files with 93 additions and 11 deletions

View File

@@ -0,0 +1,36 @@
use tokio::task::JoinSet;
use tokio::process::Command;
use std::error;
pub fn start_process(ts: &mut JoinSet<Result<(), Box<dyn error::Error + Send + Sync>>>) {
for _j in 0..5 {
ts.spawn(async move {
for _i in 0..5 {
let mut child = Command::new("sleep").arg("1")
.spawn()
.expect("failed to spawn");
match child.wait().await {
Ok(status) => {
println!("starter: sleep exited: {}", status);
},
Err(e) => {
if let Some(eos) = e.raw_os_error() {
if eos != nix::Error::ECHILD as i32 {
return Err(e.into());
}
} else {
return Err(e.into());
}
},
}
// let status = child.wait().await?;
// println!("starter: sleep exited: {}", status);
}
println!("starter: task completed");
Ok(())
});
}
println!("starter: spawning completed");
}