aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2014-11-25 23:31:55 +0100
committerMichael Kerrisk <mtk.manpages@gmail.com>2014-12-05 06:09:31 +0100
commitd6c9f01b6440e57ba9e737dd13648465087ecc75 (patch)
treeb0741285ab6270981e0120edbf06604014a12464
parenta00ca3d5a071ff4c17090361a7375d1c620865ea (diff)
downloadman-pages-d6c9f01b6440e57ba9e737dd13648465087ecc75.tar.gz
setsid.2: Rewrite some pieces and add some details
Among other changes, add an explanation of why setsid() can't be called from a process group leader Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
-rw-r--r--man2/setsid.225
1 files changed, 17 insertions, 8 deletions
diff --git a/man2/setsid.2 b/man2/setsid.2
index 40a8fe98f0..52bc88e02d 100644
--- a/man2/setsid.2
+++ b/man2/setsid.2
@@ -1,5 +1,6 @@
.\" Copyright Michael Haardt (michael@cantor.informatik.rwth-aachen.de)
.\" Sat Aug 27 20:43:50 MET DST 1994
+.\" and Copyright (C) 2014, Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
.\" This is free documentation; you can redistribute it and/or
@@ -41,13 +42,15 @@ setsid \- creates a session and sets the process group ID
.BR setsid ()
creates a new session if the calling process is not a
process group leader.
-The calling process is the leader of the new
-session, the process group leader of the new process group, and has no
-controlling terminal.
-The process group ID and session ID of the calling
-process are set to the PID of the calling process.
+The calling process is the leader of the new session
+(i.e., its session ID is made the same as it process ID).
+The calling process also becomes
+the process group leader of a new process group in the session
+(i.e., its process group ID is made the same as it process ID).
+
The calling process will be the only process in
-this new process group and in this new session.
+the new process group and in the new session.
+The new session has no controlling terminal.
.SH RETURN VALUE
On success, the (new) session ID of the calling process is returned.
On error,
@@ -71,8 +74,14 @@ inherits its parent's session ID.
The session ID is preserved across an
.BR execve (2).
-A process group leader is a process with process group ID equal
-to its PID.
+A process group leader is a process whose process group ID equals its PID.
+Disallowing a process group leader from calling
+.BR setsid()
+prevents the possibility that a process group leader places itself
+in a new session while other processes in the process group remain
+in the original session;
+such a scenario would break the strict
+two-level hierarchy of sessions and process groups.
In order to be sure that
.BR setsid ()
will succeed,