namespaces.7: ffix
[man-pages.git] / man2 / getsid.2
blobd94f5b9b016af5f2f0c0314bcf1514746620b93f
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 2021-03-22 "Linux" "Linux Programmer's Manual"
28 .SH NAME
29 getsid \- get session ID
30 .SH SYNOPSIS
31 .nf
32 .B #include <unistd.h>
33 .PP
34 .BI "pid_t getsid(pid_t" " pid" );
35 .fi
36 .PP
37 .RS -4
38 Feature Test Macro Requirements for glibc (see
39 .BR feature_test_macros (7)):
40 .RE
41 .PP
42 .BR getsid ():
43 .nf
44     _XOPEN_SOURCE >= 500
45 .\"    || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
46         || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
47 .fi
48 .SH DESCRIPTION
49 .I getsid(0)
50 returns the session ID of the calling process.
51 .BR getsid ()
52 returns the session ID of the process with process ID
53 .IR pid .
55 .I pid
56 is 0,
57 .BR getsid ()
58 returns the session ID of the calling process.
59 .SH RETURN VALUE
60 On success, a session ID is returned.
61 On error, \fI(pid_t)\ \-1\fP is returned, and
62 .I errno
63 is set to indicate the error.
64 .SH ERRORS
65 .TP
66 .B EPERM
67 A process with process ID
68 .I pid
69 exists, but it is not in the same session as the calling process,
70 and the implementation considers this an error.
71 .TP
72 .B ESRCH
73 No process with process ID
74 .I pid
75 was found.
76 .SH VERSIONS
77 This system call is available on Linux since version 2.0.
78 .\" Linux has this system call since Linux 1.3.44.
79 .\" There is libc support since libc 5.2.19.
80 .SH CONFORMING TO
81 POSIX.1-2001, POSIX.1-2008, SVr4.
82 .SH NOTES
83 Linux does not return
84 .BR EPERM .
85 .PP
86 See
87 .BR credentials (7)
88 for a description of sessions and session IDs.
89 .SH SEE ALSO
90 .BR getpgid (2),
91 .BR setsid (2),
92 .BR credentials (7)