1PTSNAME(3) Linux Programmer's Manual PTSNAME(3)
2
3
4
6 ptsname, ptsname_r - get the name of the slave pseudoterminal
7
9 #include <stdlib.h>
10
11 char *ptsname(int fd);
12 int ptsname_r(int fd, char *buf, size_t buflen);
13
14 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16 ptsname():
17 Since glibc 2.24:
18 _XOPEN_SOURCE >= 500 ||
19 (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED)
20 Glibc 2.23 and earlier:
21 _XOPEN_SOURCE
22
23 ptsname_r():
24 _GNU_SOURCE
25
27 The ptsname() function returns the name of the slave pseudoterminal
28 device corresponding to the master referred to by fd.
29
30 The ptsname_r() function is the reentrant equivalent of ptsname(). It
31 returns the name of the slave pseudoterminal device as a null-termi‐
32 nated string in the buffer pointed to by buf. The buflen argument
33 specifies the number of bytes available in buf.
34
36 On success, ptsname() returns a pointer to a string in static storage
37 which will be overwritten by subsequent calls. This pointer must not
38 be freed. On failure, NULL is returned.
39
40 On success, ptsname_r() returns 0. On failure, a nonzero value is
41 returned and errno is set to indicate the error.
42
44 EINVAL (ptsname_r() only) buf is NULL. (This error is returned only
45 for glibc 2.25 and earlier.)
46
47 ENOTTY fd does not refer to a pseudoterminal master device.
48
49 ERANGE (ptsname_r() only) buf is too small.
50
52 ptsname() is provided in glibc since version 2.1.
53
55 For an explanation of the terms used in this section, see
56 attributes(7).
57
58 ┌────────────┬───────────────┬────────────────────────┐
59 │Interface │ Attribute │ Value │
60 ├────────────┼───────────────┼────────────────────────┤
61 │ptsname() │ Thread safety │ MT-Unsafe race:ptsname │
62 ├────────────┼───────────────┼────────────────────────┤
63 │ptsname_r() │ Thread safety │ MT-Safe │
64 └────────────┴───────────────┴────────────────────────┘
66 ptsname():
67 POSIX.1-2001, POSIX.1-2008.
68
69 ptsname() is part of the UNIX 98 pseudoterminal support (see pts(4)).
70
71 ptsname_r() is a Linux extension, that is proposed for inclusion in the
72 next major revision of POSIX.1 (Issue 8). A version of this function
73 is documented on Tru64 and HP-UX, but on those implementations, -1 is
74 returned on error, with errno set to indicate the error. Avoid using
75 this function in portable programs.
76
78 grantpt(3), posix_openpt(3), ttyname(3), unlockpt(3), pts(4), pty(7)
79
81 This page is part of release 5.02 of the Linux man-pages project. A
82 description of the project, information about reporting bugs, and the
83 latest version of this page, can be found at
84 https://www.kernel.org/doc/man-pages/.
85
86
87
88 2017-09-15 PTSNAME(3)