]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/libc/stdlib/ptsname.3
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / lib / libc / stdlib / ptsname.3
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 .\"
32 .\" $FreeBSD$
33 .\"
34 .Dd August 20, 2008
35 .Dt PTSNAME 3
36 .Os
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
53 The
54 .Fn grantpt ,
55 .Fn ptsname ,
56 and
57 .Fn unlockpt
58 functions allow access to pseudo-terminal devices.
59 These three functions accept a file descriptor that references the
60 master half of a pseudo-terminal pair.
61 This file descriptor is created with
62 .Xr posix_openpt 2 .
63 .Pp
64 The
65 .Fn grantpt
66 function is used to establish ownership and permissions
67 of the slave device counterpart to the master device
68 specified with
69 .Fa fildes .
70 The slave device's ownership is set to the real user ID
71 of the calling process, and the permissions are set to
72 user readable-writable and group writable.
73 The group owner of the slave device is also set to the
74 group
75 .Dq Li tty .
76 .Pp
77 The
78 .Fn ptsname
79 function returns the full pathname of the slave device
80 counterpart to the master device specified with
81 .Fa fildes .
82 This value can be used
83 to subsequently open the appropriate slave after
84 .Xr posix_openpt 2
85 and
86 .Fn grantpt
87 have been called.
88 .Pp
89 The
90 .Fn unlockpt
91 function clears the lock held on the pseudo-terminal pair
92 for the master device specified with
93 .Fa fildes .
94 .Sh RETURN VALUES
95 .Rv -std grantpt unlockpt
96 .Pp
97 The
98 .Fn ptsname
99 function returns a pointer to the name
100 of the slave device on success; otherwise a
101 .Dv NULL
102 pointer is returned.
103 .Sh ERRORS
104 The
105 .Fn grantpt ,
106 .Fn ptsname
107 and
108 .Fn unlockpt
109 functions may fail and set
110 .Va errno
111 to:
112 .Bl -tag -width Er
113 .It Bq Er EBADF
114 .Fa fildes
115 is not a valid open file descriptor.
116 .It Bq Er EINVAL
117 .Fa fildes
118 is not a master pseudo-terminal device.
119 .El
120 .Pp
121 In addition, the
122 .Fn grantpt
123 function may set
124 .Va errno
125 to:
126 .Bl -tag -width Er
127 .It Bq Er EACCES
128 The slave pseudo-terminal device could not be accessed.
129 .El
130 .Sh SEE ALSO
131 .Xr posix_openpt 2 ,
132 .Xr pts 4 ,
133 .Xr tty 4
134 .Sh STANDARDS
135 The
136 .Fn ptsname
137 function conforms to
138 .St -p1003.1-2008 .
139 .Pp
140 This implementation of
141 .Fn grantpt
142 and
143 .Fn unlockpt
144 does not conform to
145 .St -p1003.1-2008 ,
146 because it depends on
147 .Xr posix_openpt 2
148 to create the pseudo-terminal device with proper permissions in place.
149 It only validates whether
150 .Fa fildes
151 is a valid pseudo-terminal master device.
152 Future revisions of the specification will likely allow this behaviour,
153 as stated by the Austin Group.
154 .Sh HISTORY
155 The
156 .Fn grantpt ,
157 .Fn ptsname
158 and
159 .Fn unlockpt
160 functions appeared in
161 .Fx 5.0 .