summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-02-06 04:37:12 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-02-06 04:37:12 +0000
commit90e82ed3d1bb03921f2b4c447f1a93fa1a4b33fc (patch)
treef11ca3295133a72a83c27d4a4b44fc214f54507d /src
parent60aaa0da2e880e6e094baed10a8a441a6d4a9c5f (diff)
parent5e999457689e4dabbc1720ea9ce684ef78286df0 (diff)
downloadnix-90e82ed3d1bb03921f2b4c447f1a93fa1a4b33fc.zip
Merge #851
851: Added `getsid` in `::nix::unistd` r=asomers a=ggriffiniii Resolves Issue #850
Diffstat (limited to 'src')
-rw-r--r--src/unistd.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/unistd.rs b/src/unistd.rs
index 5f3a3806..8022aa0b 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -264,6 +264,17 @@ pub fn setsid() -> Result<Pid> {
Errno::result(unsafe { libc::setsid() }).map(Pid)
}
+/// Get the process group ID of a session leader
+/// [getsid(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsid.html).
+///
+/// Obtain the process group ID of the process that is the session leader of the process specified
+/// by pid. If pid is zero, it specifies the calling process.
+#[inline]
+pub fn getsid(pid: Option<Pid>) -> Result<Pid> {
+ let res = unsafe { libc::getsid(pid.unwrap_or(Pid(0)).into()) };
+ Errno::result(res).map(Pid)
+}
+
/// Get the terminal foreground process group (see
/// [tcgetpgrp(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetpgrp.html)).