1PTSNAME(3)                 Linux Programmer's Manual                PTSNAME(3)
2
3
4

NAME

6       ptsname, ptsname_r - get the name of the slave pseudoterminal
7

SYNOPSIS

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           Glibc 2.23 and earlier:
20               _XOPEN_SOURCE
21
22       ptsname_r():
23           _GNU_SOURCE
24

DESCRIPTION

26       The ptsname() function returns the name of the slave pseudoterminal de‐
27       vice corresponding to the master referred to by the file descriptor fd.
28
29       The ptsname_r() function is the reentrant equivalent of ptsname().   It
30       returns  the  name  of the slave pseudoterminal device as a null-termi‐
31       nated string in the buffer pointed to  by  buf.   The  buflen  argument
32       specifies the number of bytes available in buf.
33

RETURN VALUE

35       On  success,  ptsname() returns a pointer to a string in static storage
36       which will be overwritten by subsequent calls.  This pointer  must  not
37       be freed.  On failure, NULL is returned.
38
39       On  success, ptsname_r() returns 0.  On failure, an error number is re‐
40       turned to indicate the error.
41

ERRORS

43       EINVAL (ptsname_r() only) buf is NULL.  (This error  is  returned  only
44              for glibc 2.25 and earlier.)
45
46       ENOTTY fd does not refer to a pseudoterminal master device.
47
48       ERANGE (ptsname_r() only) buf is too small.
49

VERSIONS

51       ptsname() is provided in glibc since version 2.1.
52

ATTRIBUTES

54       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
55       tributes(7).
56
57       ┌─────────────────────────────┬───────────────┬────────────────────────┐
58Interface                    Attribute     Value                  
59       ├─────────────────────────────┼───────────────┼────────────────────────┤
60ptsname()                    │ Thread safety │ MT-Unsafe race:ptsname │
61       ├─────────────────────────────┼───────────────┼────────────────────────┤
62ptsname_r()                  │ Thread safety │ MT-Safe                │
63       └─────────────────────────────┴───────────────┴────────────────────────┘
64

CONFORMING TO

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

SEE ALSO

78       grantpt(3), posix_openpt(3), ttyname(3), unlockpt(3), pts(4), pty(7)
79

COLOPHON

81       This page is part of release 5.12 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                                  2021-03-22                        PTSNAME(3)
Impressum