[−][src]Function sys_util::reap_child
pub fn reap_child() -> Result<pid_t>
Reaps a child process that has terminated.
Returns Ok(pid)
where pid
is the process that was reaped or Ok(0)
if none of the children
have terminated. An Error
is with errno == ECHILD
if there are no children left to reap.
Examples
Reaps all child processes until there are no terminated children to reap.
fn reap_children() { loop { match sys_util::reap_child() { Ok(0) => println!("no children ready to reap"), Ok(pid) => { println!("reaped {}", pid); continue }, Err(e) if e.errno() == libc::ECHILD => println!("no children left"), Err(e) => println!("error reaping children: {:?}", e), } break } }