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