wait for all child

This commit is contained in:
guochao 2023-11-03 10:18:12 +08:00
parent e1ba2f7141
commit d422f30774

View File

@ -1,7 +1,7 @@
use nix::{ use nix::{
libc::{c_long, EPERM, ORIG_RAX}, libc::{c_long, EPERM, ORIG_RAX},
sys::stat::Mode, sys::stat::Mode,
unistd::{getpid, getppid}, unistd::{getpid, getppid, Pid},
}; };
use std::io::Write; use std::io::Write;
use std::{ use std::{
@ -74,7 +74,7 @@ fn main() -> anyhow::Result<()> {
loop { loop {
log::debug!("parent: waitpid..."); log::debug!("parent: waitpid...");
let waitstatus = waitpid(child, None)?; let waitstatus = waitpid(Pid::from_raw(-1), None)?;
match waitstatus { match waitstatus {
WaitStatus::Exited(pid, ret) => { WaitStatus::Exited(pid, ret) => {