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