diff options
author | Paul Osborne <osbpau@gmail.com> | 2016-10-27 21:58:41 -0400 |
---|---|---|
committer | Paul Osborne <osbpau@gmail.com> | 2016-10-27 21:58:41 -0400 |
commit | 4a20c0730c2bedf7dbc8f2df8ad7a9054273ed3c (patch) | |
tree | ce057e9b73cd686a3a94e8544ac0420f92be7eb3 /src/unistd.rs | |
parent | 020baa801e541a9d7846b1e99f1dce81a31b7ac5 (diff) | |
download | nix-4a20c0730c2bedf7dbc8f2df8ad7a9054273ed3c.zip |
unistd: add docs for getpid/getppid
Signed-off-by: Paul Osborne <osbpau@gmail.com>
Diffstat (limited to 'src/unistd.rs')
-rw-r--r-- | src/unistd.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/unistd.rs b/src/unistd.rs index 257f3cd2..81a342e3 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -82,14 +82,26 @@ pub fn fork() -> Result<ForkResult> { }) } +/// Get the pid of this process (see +/// [getpid(2)](http://man7.org/linux/man-pages/man2/getpid.2.html)). +/// +/// Since you are running code, there is always a pid to return, so there +/// is no error case that needs to be handled. #[inline] pub fn getpid() -> pid_t { - unsafe { libc::getpid() } // no error handling, according to man page: "These functions are always successful." + unsafe { libc::getpid() } } + +/// Get the pid of this processes' parent (see +/// [getpid(2)](http://man7.org/linux/man-pages/man2/getpid.2.html)). +/// +/// There is always a parent pid to return, so there is no error case that needs +/// to be handled. #[inline] pub fn getppid() -> pid_t { unsafe { libc::getppid() } // no error handling, according to man page: "These functions are always successful." } + #[inline] pub fn setpgid(pid: pid_t, pgid: pid_t) -> Result<()> { let res = unsafe { libc::setpgid(pid, pgid) }; |