| 1 |
'\" t |
| 2 |
.\" Copyright 2002, Andries E. Brouwer <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH tcgetsid 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
tcgetsid \- get session ID |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.BR "#define _XOPEN_SOURCE 500" " /* See feature_test_macros(7) */" |
| 16 |
.B "#include <termios.h>" |
| 17 |
.P |
| 18 |
.BI "pid_t tcgetsid(int " fd ); |
| 19 |
.fi |
| 20 |
.SH DESCRIPTION |
| 21 |
The function |
| 22 |
.BR tcgetsid () |
| 23 |
returns the session ID of the current session that has the |
| 24 |
terminal associated to |
| 25 |
.I fd |
| 26 |
as controlling terminal. |
| 27 |
This terminal must be the controlling terminal of the calling process. |
| 28 |
.SH RETURN VALUE |
| 29 |
When |
| 30 |
.I fd |
| 31 |
refers to the controlling terminal of our session, |
| 32 |
the function |
| 33 |
.BR tcgetsid () |
| 34 |
will return the session ID of this session. |
| 35 |
Otherwise, \-1 is returned, and |
| 36 |
.I errno |
| 37 |
is set to indicate the error. |
| 38 |
.SH ERRORS |
| 39 |
.TP |
| 40 |
.B EBADF |
| 41 |
.I fd |
| 42 |
is not a valid file descriptor. |
| 43 |
.TP |
| 44 |
.B ENOTTY |
| 45 |
The calling process does not have a controlling terminal, or |
| 46 |
it has one but it is not described by |
| 47 |
.IR fd . |
| 48 |
.SH ATTRIBUTES |
| 49 |
For an explanation of the terms used in this section, see |
| 50 |
.BR attributes (7). |
| 51 |
.TS |
| 52 |
allbox; |
| 53 |
lbx lb lb |
| 54 |
l l l. |
| 55 |
Interface Attribute Value |
| 56 |
T{ |
| 57 |
.na |
| 58 |
.nh |
| 59 |
.BR tcgetsid () |
| 60 |
T} Thread safety MT-Safe |
| 61 |
.TE |
| 62 |
.SH STANDARDS |
| 63 |
POSIX.1-2008. |
| 64 |
.SH HISTORY |
| 65 |
glibc 2.1. |
| 66 |
POSIX.1-2001. |
| 67 |
.P |
| 68 |
This function is implemented via the |
| 69 |
.B TIOCGSID |
| 70 |
.BR ioctl (2), |
| 71 |
present |
| 72 |
since Linux 2.1.71. |
| 73 |
.SH SEE ALSO |
| 74 |
.BR getsid (2) |