OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / 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 .SS Multithreading (see pthreads(7))
81 The
82 .BR ptsname ()
83 function is not thread-safe.
84 .LP
85 The
86 .BR ptsname_r ()
87 function is thread-safe.
88 .SH CONFORMING TO
89 .BR ptsname ()
90 is part of the UNIX 98 pseudoterminal support (see
91 .BR pts (4)).
92 This function is specified in POSIX.1-2001.
93
94 .BR ptsname_r ()
95 is a Linux extension.
96 A version of this function is documented on Tru64 and HP-UX, but
97 on those implementations, \-1 is returned on error, with
98 .I errno
99 set to indicate the error.
100 Avoid using this function in portable programs.
101 .SH SEE ALSO
102 .BR grantpt (3),
103 .BR posix_openpt (3),
104 .BR ttyname (3),
105 .BR unlockpt (3),
106 .BR pts (4),
107 .BR pty (7)
108 .SH COLOPHON
109 This page is part of release 3.68 of the Linux
110 .I man-pages
111 project.
112 A description of the project,
113 information about reporting bugs,
114 and the latest version of this page,
115 can be found at
116 \%http://www.kernel.org/doc/man\-pages/.