Skip to content

Commit 4e9401a

Browse files
committed
Document the PID argument in waitpid
1 parent d0628e1 commit 4e9401a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/sys/wait.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,19 @@ fn decode(pid : Pid, status: i32) -> WaitStatus {
215215
}
216216
}
217217

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+
/// ```
218231
pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Result<WaitStatus> {
219232
use self::WaitStatus::*;
220233

0 commit comments

Comments
 (0)