Debian Codegraph @

upstream/debian-unstable/man3/ctermid.3

raw
1 '\" t
2 .\" Copyright 1993, Thomas Koenig <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH ctermid 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 ctermid \- get controlling terminal name
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <stdio.h>
16 .\" POSIX also requires this function to be declared in <unistd.h>,
17 .\" and glibc does so if suitable feature test macros are defined.
18 .P
19 .BI "char *ctermid(char *" "s" );
20 .fi
21 .P
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .P
27 .BR ctermid ():
28 .nf
29 _POSIX_C_SOURCE
30 .fi
31 .SH DESCRIPTION
32 .BR ctermid ()
33 returns a string which is the pathname for the current
34 controlling terminal for this process.
35 If
36 .I s
37 is NULL,
38 a static buffer is used, otherwise
39 .I s
40 points to a buffer used to hold the terminal pathname.
41 The symbolic constant
42 .B L_ctermid
43 is the maximum number of characters in the returned pathname.
44 .SH RETURN VALUE
45 The pointer to the pathname.
46 .SH ATTRIBUTES
47 For an explanation of the terms used in this section, see
48 .BR attributes (7).
49 .TS
50 allbox;
51 lbx lb lb
52 l l l.
53 Interface Attribute Value
54 T{
55 .na
56 .nh
57 .BR ctermid ()
58 T} Thread safety MT-Safe
59 .TE
60 .SH STANDARDS
61 POSIX.1-2008.
62 .SH HISTORY
63 POSIX.1-2001, Svr4.
64 .SH BUGS
65 The returned pathname may not uniquely identify the controlling terminal;
66 it may, for example, be
67 .IR /dev/tty .
68 .P
69 It is not assured that the program can open the terminal.
70 .\" in glibc 2.3.x, x >= 4, the glibc headers threw an error
71 .\" if ctermid() was given an argument; fixed in glibc 2.4.
72 .SH SEE ALSO
73 .BR ttyname (3)