File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,22 @@ fn decode(pid : Pid, status: i32) -> WaitStatus {
215
215
}
216
216
}
217
217
218
+ /// Counterpart of the POSIX `waitpid` function
219
+ /// It's best to use `nix::unistd::Pid` for passing the PID to this function
220
+ ///
221
+ /// # Examples
222
+ /// ```
223
+ /// use std::process::Command;
224
+ /// use nix::unistd::Pid;
225
+ /// use nix::sys::{waitpid, WaitStatus};
226
+ /// let child = Command::new("ls").spawn().unwrap();
227
+ /// let pid = Pid::from_raw(child.id() as i32);
228
+ /// match waitpid(pid, None) {
229
+ /// Ok(WaitStatus::Exited(_, code)) => println!("Child exited with code {}", code),
230
+ /// Ok(_) => println!("Other process exited, but not normally"),
231
+ /// Err(_) => panic!("There was an error")
232
+ /// }
233
+ /// ```
218
234
pub fn waitpid < P : Into < Option < Pid > > > ( pid : P , options : Option < WaitPidFlag > ) -> Result < WaitStatus > {
219
235
use self :: WaitStatus :: * ;
220
236
You can’t perform that action at this time.
0 commit comments