Function waitid
pub unsafe fn waitid(
which: i32,
pid: i32,
info: &mut siginfo_t,
options: i32,
ru: Option<&mut rusage_t>,
) -> Result<(), 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 info = nc::siginfo_t::default();
let options = nc::WEXITED;
let ret = unsafe { nc::waitid(nc::P_ALL, -1, &mut info, options, None) };
match ret {
Err(errno) => eprintln!("waitid() error: {}", nc::strerror(errno)),
Ok(()) => {
let exited_pid = unsafe { info.siginfo.sifields.sigchld.pid };
assert_eq!(pid, exited_pid);
}
}
}
}