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