pub unsafe fn wait4(
pid: pid_t,
wstatus: &mut i32,
options: i32,
rusage: &mut rusage_t
) -> Result<pid_t, Errno>
Expand description
Wait for process to change state.
§Example
let ret = unsafe { nc::fork() };
match ret {
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 mut usage = nc::rusage_t::default();
let ret = unsafe { nc::wait4(-1, &mut status, 0, &mut usage) };
assert!(ret.is_ok());
println!("status: {}", status);
let exited_pid = ret.unwrap();
assert_eq!(exited_pid, pid);
}
}