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