We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d0628e1 commit 4e9401aCopy full SHA for 4e9401a
src/sys/wait.rs
@@ -215,6 +215,19 @@ fn decode(pid : Pid, status: i32) -> WaitStatus {
215
}
216
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
231
pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Result<WaitStatus> {
232
use self::WaitStatus::*;
233
0 commit comments