]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/setsid.2
Removed version number from .TH line
[thirdparty/man-pages.git] / man2 / setsid.2
1 .\" Copyright Michael Haardt (michael@cantor.informatik.rwth-aachen.de) Sat Aug 27 20:43:50 MET DST 1994
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" Modified Sun Sep 11 19:19:05 1994 <faith@cs.unc.edu>
24 .\" Modified Mon Mar 25 10:19:00 1996 <aeb@cwi.nl> (merged a few
25 .\" tiny changes from a man page by Charles Livingston).
26 .\" Modified Sun Jul 21 14:45:46 1996 <aeb@cwi.nl>
27 .\"
28 .TH SETSID 2 1994-08-27 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 setsid \- creates a session and sets the process group ID
31 .SH SYNOPSIS
32 .ad l
33 .B #include <unistd.h>
34 .sp
35 .B pid_t setsid(void);
36 .br
37 .ad b
38 .SH DESCRIPTION
39 .BR setsid ()
40 creates a new session if the calling process is not a
41 process group leader.
42 The calling process is the leader of the new
43 session, the process group leader of the new process group, and has no
44 controlling tty.
45 The process group ID and session ID of the calling
46 process are set to the PID of the calling process.
47 The calling process will be the only process in
48 this new process group and in this new session.
49 .SH "RETURN VALUE"
50 The session ID of the calling process.
51 .SH ERRORS
52 On error, \-1 is returned, and
53 .I errno
54 is set.
55 The only error which can happen is
56 EPERM.
57 It is returned when the process group ID of any process
58 equals the PID of the calling process.
59 Thus, in particular,
60 .BR setsid ()
61 fails if the calling process is already a process group leader.
62 .SH "CONFORMING TO"
63 SVr4, POSIX.1-2001.
64 .SH NOTES
65 A child created via
66 .BR fork (2)
67 inherits its parent's session ID.
68 The session ID is preserved across an
69 .BR execve (2).
70
71 A process group leader is a process with process group ID equal
72 to its PID.
73 In order to be sure that
74 .BR setsid ()
75 will succeed,
76 .BR fork (2)
77 and
78 .BR _exit (2),
79 and have the child do
80 .BR setsid ().
81 .SH "SEE ALSO"
82 .BR setpgid (2),
83 .BR setpgrp (2),
84 .BR tcgetsid (3)