1ptsname(3) Library Functions Manual ptsname(3)
2
3
4
6 ptsname, ptsname_r - get the name of the slave pseudoterminal
7
9 Standard C library (libc, -lc)
10
12 #include <stdlib.h>
13
14 char *ptsname(int fd);
15 int ptsname_r(int fd, char buf[.buflen], size_t buflen);
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 ptsname():
20 Since glibc 2.24:
21 _XOPEN_SOURCE >= 500
22 glibc 2.23 and earlier:
23 _XOPEN_SOURCE
24
25 ptsname_r():
26 _GNU_SOURCE
27
29 The ptsname() function returns the name of the slave pseudoterminal de‐
30 vice corresponding to the master referred to by the file descriptor fd.
31
32 The ptsname_r() function is the reentrant equivalent of ptsname(). It
33 returns the name of the slave pseudoterminal device as a null-termi‐
34 nated string in the buffer pointed to by buf. The buflen argument
35 specifies the number of bytes available in buf.
36
38 On success, ptsname() returns a pointer to a string in static storage
39 which will be overwritten by subsequent calls. This pointer must not
40 be freed. On failure, NULL is returned.
41
42 On success, ptsname_r() returns 0. On failure, an error number is re‐
43 turned to indicate the error.
44
46 EINVAL (ptsname_r() only) buf is NULL. (This error is returned only
47 for glibc 2.25 and earlier.)
48
49 ENOTTY fd does not refer to a pseudoterminal master device.
50
51 ERANGE (ptsname_r() only) buf is too small.
52
54 For an explanation of the terms used in this section, see at‐
55 tributes(7).
56
57 ┌─────────────────────────────┬───────────────┬────────────────────────┐
58 │Interface │ Attribute │ Value │
59 ├─────────────────────────────┼───────────────┼────────────────────────┤
60 │ptsname() │ Thread safety │ MT-Unsafe race:ptsname │
61 ├─────────────────────────────┼───────────────┼────────────────────────┤
62 │ptsname_r() │ Thread safety │ MT-Safe │
63 └─────────────────────────────┴───────────────┴────────────────────────┘
64
66 A version of ptsname_r() is documented on Tru64 and HP-UX, but on those
67 implementations, -1 is returned on error, with errno set to indicate
68 the error. Avoid using this function in portable programs.
69
71 ptsname():
72 POSIX.1-2008.
73
74 ptsname_r() is a Linux extension, that is proposed for inclusion in the
75 next major revision of POSIX.1 (Issue 8).
76
78 ptsname():
79 POSIX.1-2001. glibc 2.1.
80
81 ptsname() is part of the UNIX 98 pseudoterminal support (see pts(4)).
82
84 grantpt(3), posix_openpt(3), ttyname(3), unlockpt(3), pts(4), pty(7)
85
86
87
88Linux man-pages 6.04 2023-03-30 ptsname(3)