File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,19 @@ 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
+ /// let child = Command::new("ls").spawn().unwrap();
224
+ /// let pid = Pid::from_raw(child.id() as i32);
225
+ /// match waitpid(pid, None) {
226
+ /// Ok(WaitStatus::Exited(_, code)) => println!("Child exited with code {}", code),
227
+ /// Ok(_) => println!("Other process exited, but not normally"),
228
+ /// Err(_) => panic!("There was an error")
229
+ /// }
230
+ /// ```
218
231
pub fn waitpid < P : Into < Option < Pid > > > ( pid : P , options : Option < WaitPidFlag > ) -> Result < WaitStatus > {
219
232
use self :: WaitStatus :: * ;
220
233
You can’t perform that action at this time.
0 commit comments