xref: /netbsd/lib/libc/stdlib/grantpt.3 (revision 6550d01e)
1.\" $NetBSD: grantpt.3,v 1.4 2008/04/30 13:10:51 martin Exp $
2.\"
3.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Christos Zoulas.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd May 25, 2004
31.Dt GRANTPT 3
32.Os
33.Sh NAME
34.Nm grantpt
35.Nd grant access to a slave pseudo-terminal device
36.Sh LIBRARY
37.Lb libc
38.Sh SYNOPSIS
39.In stdlib.h
40.Ft int
41.Fn grantpt "int fildes"
42.Sh DESCRIPTION
43The
44.Fn grantpt
45function changes the mode and ownership of the slave pseudo-terminal device
46that corresponds to the master pseudo-terminal device associated with
47.Fa fildes
48to be owned by the real user id of the calling process, group id of
49.Dv tty .
50The permissions are set to readable and writable by owner, and writable by
51group.
52If the slave pseudo-terminal device was being accessed by other file
53descriptors at the time, all such access will be revoked.
54.Sh RETURN VALUES
55If successful,
56.Fn grantpt
57returns 0; otherwise a value of \-1 is returned and
58.Va errno
59is set to indicate the error.
60.Sh ERRORS
61The
62.Fn grantpt
63function will fail if:
64.Bl -tag -width Er
65.It Bq Er EACCESS
66the corresponding pseudo-terminal device could not be accessed.
67.It Bq Er EBADF
68.Fa fildes
69is not a valid descriptor.
70.It Bq Er EINVAL
71.Fa fildes
72is not associated with a master pseudo-terminal device.
73.El
74.Sh NOTES
75Setting the group to
76.Dv tty
77and revoking accesses by other file descriptors are
78.Nx
79extensions.
80Calling
81.Fn grantpt
82is equivalent to:
83.Bd -literal
84	ioctl(fildes, TIOCGRANTPT, 0);
85.Ed
86.Sh SEE ALSO
87.Xr ioctl 2 ,
88.Xr posix_openpt 3 ,
89.Xr ptsname 3 ,
90.Xr unlockpt 3
91.Sh STANDARDS
92The
93.Fn grantpt
94function conforms to
95.St -p1003.1-2001 .
96Its first release was in
97.St -xpg4.2 .
98