]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/grantpt.3
des_crypt.3: Minor wording fix in VERSIONS
[thirdparty/man-pages.git] / man3 / grantpt.3
CommitLineData
2d6c6dd1 1.\" %%%LICENSE_START(PUBLIC_DOMAIN)
fea681da 2.\" This page is in the public domain. - aeb
2d6c6dd1 3.\" %%%LICENSE_END
fea681da 4.\"
4b8c67d9 5.TH GRANTPT 3 2017-09-15 "GNU" "Linux Programmer's Manual"
fea681da 6.SH NAME
14f840aa 7grantpt \- grant access to the slave pseudoterminal
fea681da 8.SH SYNOPSIS
fea681da 9.B #include <stdlib.h>
68e4db0a 10.PP
fea681da 11.BI "int grantpt(int " fd ");"
68e4db0a 12.PP
c2ba3716
FT
13.in -4n
14Feature Test Macro Requirements for glibc (see
15.BR feature_test_macros (7)):
16.in
17.PP
18.ad l
19.BR grantpt ():
20.br
21.RS 4
22Since glibc 2.24:
23 _XOPEN_SOURCE\ >=\ 500 ||
24 (_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED)
25.br
26Glibc 2.23 and earlier:
27 _XOPEN_SOURCE
28.RE
29.ad
fea681da
MK
30.SH DESCRIPTION
31The
32.BR grantpt ()
14f840aa 33function changes the mode and owner of the slave pseudoterminal device
6d4268df 34corresponding to the master pseudoterminal referred to by
fea681da
MK
35.IR fd .
36The user ID of the slave is set to the real UID of the calling process.
c9942389
MK
37The group ID is set to an unspecified value (e.g.,
38.IR tty ).
fea681da
MK
39The mode of the slave is set to 0620 (crw\-\-w\-\-\-\-).
40.PP
41The behavior of
42.BR grantpt ()
8bd58774
MK
43is unspecified if a signal handler is installed to catch
44.B SIGCHLD
45signals.
47297adb 46.SH RETURN VALUE
c13182ef 47When successful,
fea681da 48.BR grantpt ()
677f4766
MK
49returns 0.
50Otherwise, it returns \-1 and sets
fea681da
MK
51.I errno
52appropriately.
53.SH ERRORS
54.TP
55.B EACCES
6d4268df 56The corresponding slave pseudoterminal could not be accessed.
fea681da
MK
57.TP
58.B EBADF
59The
60.I fd
61argument is not a valid open file descriptor.
62.TP
63.B EINVAL
64The
65.I fd
6d4268df 66argument is valid but not associated with a master pseudoterminal.
c343e74c
MK
67.SH VERSIONS
68.BR grantpt ()
69is provided in glibc since version 2.1.
f4a23dc2
MS
70.SH ATTRIBUTES
71For an explanation of the terms used in this section, see
72.BR attributes (7).
73.TS
74allbox;
75lb lb lb
76l l l.
77Interface Attribute Value
78T{
79.BR grantpt ()
80T} Thread safety MT-Safe locale
81.TE
847e0d88 82.sp 1
47297adb 83.SH CONFORMING TO
21a28f3a 84POSIX.1-2001, POSIX.1-2008.
fea681da 85.SH NOTES
6d4268df 86This is part of the UNIX 98 pseudoterminal support, see
fea681da 87.BR pts (4).
847e0d88 88.PP
880f5b4b 89Many systems implement this function via a set-user-ID helper binary
ca7b3c18 90called "pt_chown".
6dcadb9b
MK
91On Linux systems with a devpts filesystem (present since Linux 2.2),
92the kernel normally sets the correct ownership and permissions
93for the pseudoterminal slave when the master is opened
94.RB ( posix_openpt (3)),
95so that nothing must be done by
96.BR grantpt ().
97Thus, no such helper binary is required
98(and indeed it is configured to be absent during the
99glibc build that is typical on many systems).
47297adb 100.SH SEE ALSO
fea681da 101.BR open (2),
a856c2ea 102.BR posix_openpt (3),
fea681da
MK
103.BR ptsname (3),
104.BR unlockpt (3),
88ab292b
MK
105.BR pts (4),
106.BR pty (7)