Function nc::waitid [−][src]
pub fn waitid(
which: i32,
pid: pid_t,
info: &mut siginfo_t,
options: i32,
ru: &mut rusage_t
) -> Result<(), Errno>
Expand description
Wait for process to change state
let ret = nc::fork(); match ret { Err(errno) => { eprintln!("fork() error: {}", nc::strerror(errno)); nc::exit(1); } Ok(0) => println!("[child] pid is: {}", nc::getpid()), Ok(pid) => { let mut info = nc::siginfo_t::default(); let options = nc::WEXITED; let mut usage = nc::rusage_t::default(); let ret = nc::waitid(nc::P_ALL, -1, &mut info, options, &mut usage); 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); } } } }