]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/ptsname.3
ptsname.3: Reformat thread-safety information
[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 2013-06-21 "" "Linux Programmer's Manual"
8 .SH NAME
9 ptsname, ptsname_r \- get the name of the slave pseudoterminal
10 .SH SYNOPSIS
11 .nf
12 .BR "#define _XOPEN_SOURCE" " /* See feature_test_macros(7) */"
13 .br
14 .B #include <stdlib.h>
15 .sp
16 .BI "char *ptsname(int " fd ");"
17 .sp
18 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
19 .br
20 .B #include <stdlib.h>
21 .sp
22 .BI "int ptsname_r(int " fd ", char *" buf ", size_t " buflen ");"
23 .fi
24 .SH DESCRIPTION
25 The
26 .BR ptsname ()
27 function returns the name of the slave pseudoterminal device
28 corresponding to the master referred to by
29 .IR fd .
30
31 The
32 .BR ptsname_r ()
33 function is the reentrant equivalent of
34 .BR ptsname ().
35 It returns the name of the slave pseudoterminal device as a
36 null-terminated string in the buffer pointed to by
37 .IR buf .
38 The
39 .I buflen
40 argument specifies the number of bytes available in
41 .IR buf .
42 .SH RETURN VALUE
43 On success,
44 .BR ptsname ()
45 returns a pointer to a string in static storage which will be
46 overwritten by subsequent calls.
47 This pointer must not be freed.
48 On failure, NULL is returned.
49
50 On success,
51 .BR ptsname_r ()
52 returns 0.
53 On failure, a nonzero value is returned
54 and
55 .I errno
56 is set to indicate the error.
57 .\" In fact the errno value is also returned as the function
58 .\" result -- MTK, Dec 04
59 .SH ERRORS
60 .TP
61 .B EINVAL
62 .RB ( ptsname_r ()
63 only)
64 .I buf
65 is NULL.
66 .TP
67 .B ENOTTY
68 .I fd
69 does not refer to a pseudoterminal master device.
70 .TP
71 .B ERANGE
72 .RB ( ptsname_r ()
73 only)
74 .I buf
75 is too small.
76 .SH VERSIONS
77 .BR ptsname ()
78 is provided in glibc since version 2.1.
79 .SH ATTRIBUTES
80 For an explanation of the terms used in this section, see
81 .BR attributes (7).
82 .TS
83 allbox;
84 lb lb lb
85 l l l.
86 Interface Attribute Value
87 T{
88 .BR ptsname ()
89 T} Thread safety MT-Unsafe
90 T{
91 .BR ptsname_r ()
92 T} Thread safety MT-Safe
93 .TE
94 .SH CONFORMING TO
95 .BR ptsname ()
96 is part of the UNIX 98 pseudoterminal support (see
97 .BR pts (4)).
98 This function is specified in POSIX.1-2001.
99
100 .BR ptsname_r ()
101 is a Linux extension.
102 A version of this function is documented on Tru64 and HP-UX, but
103 on those implementations, \-1 is returned on error, with
104 .I errno
105 set to indicate the error.
106 Avoid using this function in portable programs.
107 .SH SEE ALSO
108 .BR grantpt (3),
109 .BR posix_openpt (3),
110 .BR ttyname (3),
111 .BR unlockpt (3),
112 .BR pts (4),
113 .BR pty (7)