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

NAME

6       grantpt - grant access to the slave pseudoterminal
7

SYNOPSIS

9       #include <stdlib.h>
10
11       int grantpt(int fd);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       grantpt():
16           Since glibc 2.24:
17               _XOPEN_SOURCE >= 500 ||
18                   (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED)
19           Glibc 2.23 and earlier:
20               _XOPEN_SOURCE
21

DESCRIPTION

23       The  grantpt()  function  changes the mode and owner of the slave pseu‐
24       doterminal device corresponding to the master  pseudoterminal  referred
25       to  by  the file descriptor fd.  The user ID of the slave is set to the
26       real UID of the calling process.  The group ID is set to an unspecified
27       value (e.g., tty).  The mode of the slave is set to 0620 (crw--w----).
28
29       The  behavior  of  grantpt()  is unspecified if a signal handler is in‐
30       stalled to catch SIGCHLD signals.
31

RETURN VALUE

33       When successful, grantpt() returns 0.  Otherwise,  it  returns  -1  and
34       sets errno appropriately.
35

ERRORS

37       EACCES The corresponding slave pseudoterminal could not be accessed.
38
39       EBADF  The fd argument is not a valid open file descriptor.
40
41       EINVAL The  fd argument is valid but not associated with a master pseu‐
42              doterminal.
43

VERSIONS

45       grantpt() is provided in glibc since version 2.1.
46

ATTRIBUTES

48       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
49       tributes(7).
50
51       ┌──────────┬───────────────┬────────────────┐
52Interface Attribute     Value          
53       ├──────────┼───────────────┼────────────────┤
54grantpt() │ Thread safety │ MT-Safe locale │
55       └──────────┴───────────────┴────────────────┘
56

CONFORMING TO

58       POSIX.1-2001, POSIX.1-2008.
59

NOTES

61       This is part of the UNIX 98 pseudoterminal support, see pts(4).
62
63       Many  systems  implement  this function via a set-user-ID helper binary
64       called "pt_chown".  On Linux systems with a devpts filesystem  (present
65       since  Linux  2.2),  the kernel normally sets the correct ownership and
66       permissions for the pseudoterminal slave  when  the  master  is  opened
67       (posix_openpt(3)), so that nothing must be done by grantpt().  Thus, no
68       such helper binary is required (and indeed it is configured to  be  ab‐
69       sent during the glibc build that is typical on many systems).
70

SEE ALSO

72       open(2), posix_openpt(3), ptsname(3), unlockpt(3), pts(4), pty(7)
73

COLOPHON

75       This  page  is  part of release 5.10 of the Linux man-pages project.  A
76       description of the project, information about reporting bugs,  and  the
77       latest     version     of     this    page,    can    be    found    at
78       https://www.kernel.org/doc/man-pages/.
79
80
81
82GNU                               2017-09-15                        GRANTPT(3)
Impressum