Skip to content

Document the PID argument in waitpid #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/sys/wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,22 @@ fn decode(pid : Pid, status: i32) -> WaitStatus {
}
}

/// Counterpart of the POSIX `waitpid` function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually describe what waitpid does with a brief summary line at the top and maybe an extended summary below it (with a blank comment line in between). Just saying it is a wrapper around waitpid isn't very helpful.

Additionally can you link to the man page in the extended description here.

/// It's best to use `nix::unistd::Pid` for passing the PID to this function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this specified by the argument type?

///
/// # Examples
/// ```
/// use std::process::Command;
/// use nix::unistd::Pid;
/// use nix::sys::wait::{waitpid, WaitStatus};
/// let child = Command::new("ls").spawn().unwrap();
/// let pid = Pid::from_raw(child.id() as i32);
/// match waitpid(pid, None) {
/// Ok(WaitStatus::Exited(_, code)) => println!("Child exited with code {}", code),
/// Ok(_) => println!("Other process exited, but not normally"),
/// Err(_) => panic!("There was an error")
/// }
/// ```
pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Result<WaitStatus> {
use self::WaitStatus::*;

Expand Down