summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlenn Griffin <ggriffiniii@gmail.com>2018-01-29 12:39:48 -0800
committerGlenn Griffin <ggriffiniii@gmail.com>2018-01-29 12:39:48 -0800
commit0384e8dc7a71031086f9065aceb9a6f5ef571af9 (patch)
tree976a3a420ecdabf7ddb3b837958402fa5bf7d145 /src
parent899eff72f92cbc300fbd7779957907a39aa0e42b (diff)
downloadnix-0384e8dc7a71031086f9065aceb9a6f5ef571af9.zip
Added `getsid` in `::nix::unistd`
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 0f47a7fc..1c858c8c 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)).