mirror of https://github.com/mkerrisk/man-pages
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>
This commit is contained in:
parent
a00ca3d5a0
commit
d6c9f01b64
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue