Debian Codegraph @

upstream/debian-unstable/man2/getsid.2

raw
1 .\" Copyright 1996, Andries E. Brouwer <[email protected]>
2 .\" Copyright 2016, Michael Kerrisk <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .\"
7 .TH getsid 2 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 getsid \- get session ID
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <unistd.h>
16 .P
17 .BI "pid_t getsid(pid_t" " pid" );
18 .fi
19 .P
20 .RS -4
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
23 .RE
24 .P
25 .BR getsid ():
26 .nf
27 _XOPEN_SOURCE >= 500
28 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
29 || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
30 .fi
31 .SH DESCRIPTION
32 .BR getsid ()
33 returns the session ID of the process with process ID
34 .IR pid .
35 If
36 .I pid
37 is 0,
38 .BR getsid ()
39 returns the session ID of the calling process.
40 .SH RETURN VALUE
41 On success, a session ID is returned.
42 On error,
43 .I (pid_t)\ \-1
44 is returned, and
45 .I errno
46 is set to indicate the error.
47 .SH ERRORS
48 .TP
49 .B EPERM
50 A process with process ID
51 .I pid
52 exists, but it is not in the same session as the calling process,
53 and the implementation considers this an error.
54 .TP
55 .B ESRCH
56 No process with process ID
57 .I pid
58 was found.
59 .SH VERSIONS
60 Linux does not return
61 .BR EPERM .
62 .SH STANDARDS
63 POSIX.1-2024.
64 .SH HISTORY
65 SVr4,
66 SUSv1,
67 Linux 2.0,
68 POSIX.1-2001 XSI,
69 POSIX.1-2008.
70 .\" Linux has this system call since Linux 1.3.44.
71 .\" There is libc support since libc 5.2.19.
72 .SH NOTES
73 See
74 .BR credentials (7)
75 for a description of sessions and session IDs.
76 .SH SEE ALSO
77 .BR getpgid (2),
78 .BR setsid (2),
79 .BR credentials (7)