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           Glibc 2.23 and earlier:
19               _XOPEN_SOURCE
20

DESCRIPTION

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

RETURN VALUE

32       When successful, grantpt() returns 0.  Otherwise,  it  returns  -1  and
33       sets errno to indicate the error.
34

ERRORS

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

VERSIONS

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

ATTRIBUTES

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

CONFORMING TO

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

NOTES

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

SEE ALSO

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

COLOPHON

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