]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/getsid.2
sched_setattr.2: tfix
[thirdparty/man-pages.git] / man2 / getsid.2
1 .\" Copyright (C) 1996 Andries Brouwer (aeb@cwi.nl)
2 .\" and Copyright (C) 2016 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified Thu Oct 31 14:18:40 1996 by Eric S. Raymond <esr@y\thyrsus.com>
26 .\" Modified 2001-12-17, aeb
27 .TH GETSID 2 2017-09-15 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 getsid \- get session ID
30 .SH SYNOPSIS
31 .B #include <sys/types.h>
32 .br
33 .B #include <unistd.h>
34 .PP
35 .BI "pid_t getsid(pid_t" " pid" );
36 .PP
37 .in -4n
38 Feature Test Macro Requirements for glibc (see
39 .BR feature_test_macros (7)):
40 .in
41 .PP
42 .ad l
43 .PD 0
44 .BR getsid ():
45 .RS 4
46 _XOPEN_SOURCE\ >=\ 500
47 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
48 .br
49 || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
50 .RE
51 .PD
52 .ad
53 .SH DESCRIPTION
54 .I getsid(0)
55 returns the session ID of the calling process.
56 .BR getsid ()
57 returns the session ID of the process with process ID
58 .IR pid .
59 If
60 .I pid
61 is 0,
62 .BR getsid ()
63 returns the session ID of the calling process.
64 .SH RETURN VALUE
65 On success, a session ID is returned.
66 On error, \fI(pid_t)\ \-1\fP will be returned, and
67 .I errno
68 is set appropriately.
69 .SH ERRORS
70 .TP
71 .B EPERM
72 A process with process ID
73 .I pid
74 exists, but it is not in the same session as the calling process,
75 and the implementation considers this an error.
76 .TP
77 .B ESRCH
78 No process with process ID
79 .I pid
80 was found.
81 .SH VERSIONS
82 This system call is available on Linux since version 2.0.
83 .\" Linux has this system call since Linux 1.3.44.
84 .\" There is libc support since libc 5.2.19.
85 .SH CONFORMING TO
86 POSIX.1-2001, POSIX.1-2008, SVr4.
87 .SH NOTES
88 Linux does not return
89 .BR EPERM .
90 .PP
91 See
92 .BR credentials (7)
93 for a description of sessions and session IDs.
94 .SH SEE ALSO
95 .BR getpgid (2),
96 .BR setsid (2),
97 .BR credentials (7)