| 1 |
'\" t |
| 2 |
.\" %%%LICENSE_START(PUBLIC_DOMAIN) |
| 3 |
.\" This page is in the public domain. - aeb |
| 4 |
.\" %%%LICENSE_END |
| 5 |
.\" |
| 6 |
.TH grantpt 3 2025-09-21 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
grantpt \- grant access to the slave pseudoterminal |
| 9 |
.SH LIBRARY |
| 10 |
Standard C library |
| 11 |
.RI ( libc ,\~ \-lc ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.B #define _XOPEN_SOURCE |
| 15 |
.B #include <stdlib.h> |
| 16 |
.P |
| 17 |
.BI "int grantpt(int " fd ");" |
| 18 |
.fi |
| 19 |
.P |
| 20 |
.RS -4 |
| 21 |
Feature Test Macro Requirements for glibc (see |
| 22 |
.BR feature_test_macros (7)): |
| 23 |
.RE |
| 24 |
.P |
| 25 |
.BR grantpt (): |
| 26 |
.nf |
| 27 |
Since glibc 2.24: |
| 28 |
_XOPEN_SOURCE >= 500 |
| 29 |
.\" || (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) |
| 30 |
glibc 2.23 and earlier: |
| 31 |
_XOPEN_SOURCE |
| 32 |
.fi |
| 33 |
.SH DESCRIPTION |
| 34 |
The |
| 35 |
.BR grantpt () |
| 36 |
function changes the mode and owner of the slave pseudoterminal device |
| 37 |
corresponding to the master pseudoterminal referred to by the file descriptor |
| 38 |
.IR fd . |
| 39 |
The user ID of the slave is set to the real UID of the calling process. |
| 40 |
The group ID is set to an unspecified value (e.g., |
| 41 |
.IR tty ). |
| 42 |
The mode of the slave is set to 0620 (crw\-\-w\-\-\-\-). |
| 43 |
.P |
| 44 |
The behavior of |
| 45 |
.BR grantpt () |
| 46 |
is unspecified if a signal handler is installed to catch |
| 47 |
.B SIGCHLD |
| 48 |
signals. |
| 49 |
.SH RETURN VALUE |
| 50 |
When successful, |
| 51 |
.BR grantpt () |
| 52 |
returns 0. |
| 53 |
Otherwise, it returns \-1 and sets |
| 54 |
.I errno |
| 55 |
to indicate the error. |
| 56 |
.SH ERRORS |
| 57 |
.TP |
| 58 |
.B EACCES |
| 59 |
The corresponding slave pseudoterminal could not be accessed. |
| 60 |
.TP |
| 61 |
.B EBADF |
| 62 |
The |
| 63 |
.I fd |
| 64 |
argument is not a valid open file descriptor. |
| 65 |
.TP |
| 66 |
.B EINVAL |
| 67 |
The |
| 68 |
.I fd |
| 69 |
argument is valid but not associated with a master pseudoterminal. |
| 70 |
.SH ATTRIBUTES |
| 71 |
For an explanation of the terms used in this section, see |
| 72 |
.BR attributes (7). |
| 73 |
.TS |
| 74 |
allbox; |
| 75 |
lbx lb lb |
| 76 |
l l l. |
| 77 |
Interface Attribute Value |
| 78 |
T{ |
| 79 |
.na |
| 80 |
.nh |
| 81 |
.BR grantpt () |
| 82 |
T} Thread safety MT-Safe locale |
| 83 |
.TE |
| 84 |
.SH STANDARDS |
| 85 |
POSIX.1-2008. |
| 86 |
.SH HISTORY |
| 87 |
glibc 2.1. |
| 88 |
POSIX.1-2001. |
| 89 |
.P |
| 90 |
This is part of the UNIX 98 pseudoterminal support, see |
| 91 |
.BR pts (4). |
| 92 |
.P |
| 93 |
Historical systems implemented this function via a set-user-ID helper binary |
| 94 |
called "pt_chown". |
| 95 |
glibc on Linux before glibc 2.33 could do so as well, |
| 96 |
in order to support configurations with only BSD pseudoterminals; |
| 97 |
this support has been removed. |
| 98 |
On modern systems this is either a no-op |
| 99 |
\[em]with permissions configured on pty allocation, as is the case on Linux\[em] |
| 100 |
or an |
| 101 |
.BR ioctl (2). |
| 102 |
.SH SEE ALSO |
| 103 |
.BR open (2), |
| 104 |
.BR posix_openpt (3), |
| 105 |
.BR ptsname (3), |
| 106 |
.BR unlockpt (3), |
| 107 |
.BR pts (4), |
| 108 |
.BR pty (7) |