malloc.3: ffix
[man-pages.git] / man3 / ptsname.3
blob8c2260cf035360565f773bc19bb07a4341b1c350
1 .\" %%%LICENSE_START(PUBLIC_DOMAIN)
2 .\" This page is in the public domain. - aeb
3 .\" %%%LICENSE_END
4 .\"
5 .\" 2004-12-17, mtk, added description of ptsname_r() + ERRORS
6 .\"
7 .TH PTSNAME 3 2021-03-22 "" "Linux Programmer's Manual"
8 .SH NAME
9 ptsname, ptsname_r \- get the name of the slave pseudoterminal
10 .SH SYNOPSIS
11 .nf
12 .B #include <stdlib.h>
13 .PP
14 .BI "char *ptsname(int " fd ");"
15 .BI "int ptsname_r(int " fd ", char *" buf ", size_t " buflen ");"
16 .fi
17 .PP
18 .RS -4
19 Feature Test Macro Requirements for glibc (see
20 .BR feature_test_macros (7)):
21 .RE
22 .PP
23 .BR ptsname ():
24 .nf
25     Since glibc 2.24:
26         _XOPEN_SOURCE >= 500
27 .\"        || (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED)
28     Glibc 2.23 and earlier:
29         _XOPEN_SOURCE
30 .fi
31 .PP
32 .BR ptsname_r ():
33 .nf
34     _GNU_SOURCE
35 .fi
36 .SH DESCRIPTION
37 The
38 .BR ptsname ()
39 function returns the name of the slave pseudoterminal device
40 corresponding to the master referred to by the file descriptor
41 .IR fd .
42 .PP
43 The
44 .BR ptsname_r ()
45 function is the reentrant equivalent of
46 .BR ptsname ().
47 It returns the name of the slave pseudoterminal device as a
48 null-terminated string in the buffer pointed to by
49 .IR buf .
50 The
51 .I buflen
52 argument specifies the number of bytes available in
53 .IR buf .
54 .SH RETURN VALUE
55 On success,
56 .BR ptsname ()
57 returns a pointer to a string in static storage which will be
58 overwritten by subsequent calls.
59 This pointer must not be freed.
60 On failure, NULL is returned.
61 .PP
62 On success,
63 .BR ptsname_r ()
64 returns 0.
65 On failure, an error number is returned to indicate the error.
66 .\" In glibc, the error number is not only returned as the return value
67 .\" but also stored in errno. But this is not true for musl libc.
68 .SH ERRORS
69 .TP
70 .B EINVAL
71 .RB ( ptsname_r ()
72 only)
73 .I buf
74 is NULL.
75 (This error is returned only for
76 .\" glibc commit 8f0a947cf55f3b0c4ebdf06953c57eff67a22fa9
77 glibc 2.25 and earlier.)
78 .TP
79 .B ENOTTY
80 .I fd
81 does not refer to a pseudoterminal master device.
82 .TP
83 .B ERANGE
84 .RB ( ptsname_r ()
85 only)
86 .I buf
87 is too small.
88 .SH VERSIONS
89 .BR ptsname ()
90 is provided in glibc since version 2.1.
91 .SH ATTRIBUTES
92 For an explanation of the terms used in this section, see
93 .BR attributes (7).
94 .ad l
95 .nh
96 .TS
97 allbox;
98 lbx lb lb
99 l l l.
100 Interface       Attribute       Value
102 .BR ptsname ()
103 T}      Thread safety   MT-Unsafe race:ptsname
105 .BR ptsname_r ()
106 T}      Thread safety   MT-Safe
110 .sp 1
111 .SH CONFORMING TO
112 .BR ptsname ():
113  POSIX.1-2001, POSIX.1-2008.
115 .BR ptsname ()
116 is part of the UNIX 98 pseudoterminal support (see
117 .BR pts (4)).
119 .BR ptsname_r ()
120 is a Linux extension, that is proposed for inclusion
121 .\" FIXME . for later review when Issue 8 is one day released
122 .\" http://austingroupbugs.net/tag_view_page.php?tag_id=8
123 .\" http://austingroupbugs.net/view.php?id=508
124 in the next major revision of POSIX.1 (Issue 8).
125 A version of this function is documented on Tru64 and HP-UX, but
126 on those implementations, \-1 is returned on error, with
127 .I errno
128 set to indicate the error.
129 Avoid using this function in portable programs.
130 .SH SEE ALSO
131 .BR grantpt (3),
132 .BR posix_openpt (3),
133 .BR ttyname (3),
134 .BR unlockpt (3),
135 .BR pts (4),
136 .BR pty (7)