gdb - Local mods (compile)
[dragonfly.git] / lib / libc / stdlib / ptsname.3
CommitLineData
a85b8d87
AH
1.\"
2.\" Copyright (c) 2002 The FreeBSD Project, Inc.
3.\" All rights reserved.
4.\"
5.\" This software includes code contributed to the FreeBSD Project
6.\" by Ryan Younce of North Carolina State University.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the FreeBSD Project nor the names of its
17.\" contributors may be used to endorse or promote products derived from
18.\" this software without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT AND CONTRIBUTORS
21.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23.\" PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT
24.\" OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26.\" TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27.\" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
fb5b3747 32.\" $FreeBSD: src/lib/libc/stdlib/ptsname.3,v 1.4 2010/04/14 19:08:06 uqs Exp $
a85b8d87
AH
33.\"
34.Dd September 10, 2009
a85b8d87 35.Dt PTSNAME 3
fb5b3747 36.Os
a85b8d87
AH
37.Sh NAME
38.Nm grantpt ,
39.Nm ptsname ,
40.Nm unlockpt
41.Nd pseudo-terminal access functions
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.In stdlib.h
46.Ft int
47.Fn grantpt "int fildes"
48.Ft "char *"
49.Fn ptsname "int fildes"
50.Ft int
51.Fn unlockpt "int fildes"
52.Sh DESCRIPTION
53The
54.Fn grantpt ,
55.Fn ptsname ,
56and
57.Fn unlockpt
58functions allow access to pseudo-terminal devices.
59These three functions accept a file descriptor that references the
60master half of a pseudo-terminal pair.
61This file descriptor is created with
62.Xr posix_openpt 3
63or by calling
64.Xr open 2
65on
66.Pa /dev/ptmx .
67.Pp
68The
69.Fn grantpt
70function is used to establish ownership and permissions
71of the slave device counterpart to the master device
72specified with
73.Fa fildes .
74The slave device's ownership is set to the real user ID
75of the calling process, and the permissions are set to
76user readable-writable and group writable.
77The group owner of the slave device is also set to the
78group
79.Dq Li tty .
80.Pp
81The
82.Fn ptsname
83function returns the full pathname of the slave device
84counterpart to the master device specified with
85.Fa fildes .
86This value can be used
87to subsequently open the appropriate slave after
88.Xr posix_openpt 3
89and
90.Fn grantpt
91have been called.
92.Pp
93The
94.Fn unlockpt
95function clears the lock held on the pseudo-terminal pair
96for the master device specified with
97.Fa fildes .
98.Sh RETURN VALUES
99.Rv -std grantpt unlockpt
100.Pp
101The
102.Fn ptsname
103function returns a pointer to the name
104of the slave device on success; otherwise a
105.Dv NULL
106pointer is returned.
107.Sh ERRORS
108The
109.Fn grantpt
110and
111.Fn unlockpt
112functions may fail and set
113.Va errno
114to:
115.Bl -tag -width Er
116.It Bq Er EBADF
117.Fa fildes
118is not a valid open file descriptor.
119.It Bq Er EINVAL
120.Fa fildes
121is not a master pseudo-terminal device.
122.El
123.Pp
124In addition, the
125.Fn grantpt
126function may set
127.Va errno
128to:
129.Bl -tag -width Er
130.It Bq Er EACCES
131The slave pseudo-terminal device could not be accessed.
132.El
133.Sh SEE ALSO
134.Xr posix_openpt 3 ,
135.Xr tty 4
136.Sh STANDARDS
137The
138.Fn ptsname
139function conforms to
140.St -p1003.1-2008 .
141.Pp
142This implementation of
143.Fn grantpt
144and
145.Fn unlockpt
146does not conform to
147.St -p1003.1-2008 ,
148because it depends on
149.Xr posix_openpt 3
150to create the pseudo-terminal device with proper permissions in place.
151It only validates whether
152.Fa fildes
153is a valid pseudo-terminal master device.
154Future revisions of the specification will likely allow this behaviour,
155as stated by the Austin Group.
156.Sh HISTORY
157The
158.Fn grantpt ,
159.Fn ptsname
160and
161.Fn unlockpt
162functions appeared in
163.Dx 2.3 .