Function wait4
pub unsafe fn wait4(
pid: i32,
wstatus: Option<&mut i32>,
options: i32,
rusage: Option<&mut rusage_t>,
) -> Result<i32, i32> ⓘ
Available on crate feature
dep_nc
only.Expand description
Wait for process to change state.
§Examples
let pid = unsafe { nc::fork() };
match pid {
Err(errno) => {
eprintln!("fork() error: {}", nc::strerror(errno));
unsafe { nc::exit(1) };
}
Ok(0) => println!("[child] pid is: {}", unsafe { nc::getpid() }),
Ok(pid) => {
let mut status = 0;
let ret = unsafe { nc::wait4(-1, Some(&mut status), 0, None) };
assert!(ret.is_ok());
println!("status: {}", status);
let exited_pid = ret.unwrap();
assert_eq!(exited_pid, pid);
}
}