1grantpt(3)                 Library Functions Manual                 grantpt(3)
2
3
4

NAME

6       grantpt - grant access to the slave pseudoterminal
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

35       When successful, grantpt() returns 0.  Otherwise,  it  returns  -1  and
36       sets errno to indicate the error.
37

ERRORS

39       EACCES The corresponding slave pseudoterminal could not be accessed.
40
41       EBADF  The fd argument is not a valid open file descriptor.
42
43       EINVAL The  fd argument is valid but not associated with a master pseu‐
44              doterminal.
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

VERSIONS

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

STANDARDS

66       POSIX.1-2008.
67

HISTORY

69       glibc 2.1.  POSIX.1-2001.
70
71       This is part of the UNIX 98 pseudoterminal support, see pts(4).
72

SEE ALSO

74       open(2), posix_openpt(3), ptsname(3), unlockpt(3), pts(4), pty(7)
75
76
77
78Linux man-pages 6.04              2023-03-30                        grantpt(3)
Impressum