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

STANDARDS

57       POSIX.1-2008.
58

HISTORY

60       glibc 2.1.  POSIX.1-2001.
61
62       This is part of the UNIX 98 pseudoterminal support, see pts(4).
63
64       Historical  systems  implemented this function via a set-user-ID helper
65       binary called "pt_chown".  glibc on Linux before glibc 2.33 could do so
66       as   well,   in   order   to   support  configurations  with  only  BSD
67       pseudoterminals; this support has been removed.  On modern systems this
68       is either a no-op —with permissions configured on pty allocation, as is
69       the case on Linux— or an ioctl(2).
70

SEE ALSO

72       open(2), posix_openpt(3), ptsname(3), unlockpt(3), pts(4), pty(7)
73
74
75
76Linux man-pages 6.05              2023-07-20                        grantpt(3)
Impressum