]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - share/man/man4/pty.4
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / share / man / man4 / pty.4
1 .\" Copyright (c) 1983, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)pty.4       8.2 (Berkeley) 11/30/93
33 .\" $FreeBSD$
34 .\"
35 .Dd November 30, 1993
36 .Dt PTY 4
37 .Os
38 .Sh NAME
39 .Nm pty
40 .Nd pseudo terminal driver
41 .Sh SYNOPSIS
42 .Cd "device pty"
43 .Sh DESCRIPTION
44 The
45 .Nm
46 driver provides support for a device-pair termed a
47 .Em pseudo terminal .
48 A pseudo terminal is a pair of character devices, a
49 .Em master
50 device and a
51 .Em slave
52 device.
53 The slave device provides to a process an interface identical
54 to that described in
55 .Xr tty 4 .
56 However, whereas all other devices which provide the
57 interface described in
58 .Xr tty 4
59 have a hardware device of some sort behind them, the slave
60 device has, instead, another process manipulating
61 it through the master half of the pseudo terminal.
62 That is, anything written on the master device is
63 given to the slave device as input and anything written
64 on the slave device is presented as input on the master
65 device.
66 .Pp
67 The following
68 .Xr ioctl 2
69 calls apply only to pseudo terminals:
70 .Bl -tag -width TIOCREMOTE
71 .It Dv TIOCSTOP
72 Stops output to a terminal (e.g.\& like typing
73 .Ql ^S ) .
74 Takes
75 no parameter.
76 .It Dv TIOCSTART
77 Restarts output (stopped by
78 .Dv TIOCSTOP
79 or by typing
80 .Ql ^S ) .
81 Takes no parameter.
82 .It Dv TIOCPKT
83 Enable/disable
84 .Em packet
85 mode.
86 Packet mode is enabled by specifying (by reference)
87 a nonzero parameter and disabled by specifying (by reference)
88 a zero parameter.
89 When applied to the master side of a pseudo terminal, each subsequent
90 .Xr read 2
91 from the terminal will return data written on the slave part of
92 the pseudo terminal preceded by a zero byte (symbolically
93 defined as
94 .Dv TIOCPKT_DATA ) ,
95 or a single byte reflecting control
96 status information.
97 In the latter case, the byte is an inclusive-or
98 of zero or more of the bits:
99 .Bl -tag -width TIOCPKT_FLUSHWRITE
100 .It Dv TIOCPKT_FLUSHREAD
101 whenever the read queue for the terminal is flushed.
102 .It Dv TIOCPKT_FLUSHWRITE
103 whenever the write queue for the terminal is flushed.
104 .It Dv TIOCPKT_STOP
105 whenever output to the terminal is stopped a la
106 .Ql ^S .
107 .It Dv TIOCPKT_START
108 whenever output to the terminal is restarted.
109 .It Dv TIOCPKT_DOSTOP
110 whenever
111 .Em t_stopc
112 is
113 .Ql ^S
114 and
115 .Em t_startc
116 is
117 .Ql ^Q .
118 .It Dv TIOCPKT_NOSTOP
119 whenever the start and stop characters are not
120 .Ql ^S/^Q .
121 .El
122 .Pp
123 While this mode is in use, the presence of control status information
124 to be read from the master side may be detected by a
125 .Xr select 2
126 for exceptional conditions.
127 .Pp
128 This mode is used by
129 .Xr rlogin 1
130 and
131 .Xr rlogind 8
132 to implement a remote-echoed, locally
133 .Ql ^S/^Q
134 flow-controlled
135 remote login with proper back-flushing of output; it can be
136 used by other similar programs.
137 .It Dv TIOCUCNTL
138 Enable/disable a mode that allows a small number of simple user
139 .Xr ioctl 2
140 commands to be passed through the pseudo-terminal,
141 using a protocol similar to that of
142 .Dv TIOCPKT .
143 The
144 .Dv TIOCUCNTL
145 and
146 .Dv TIOCPKT
147 modes are mutually exclusive.
148 This mode is enabled from the master side of a pseudo terminal
149 by specifying (by reference)
150 a nonzero parameter and disabled by specifying (by reference)
151 a zero parameter.
152 Each subsequent
153 .Xr read 2
154 from the master side will return data written on the slave part of
155 the pseudo terminal preceded by a zero byte,
156 or a single byte reflecting a user control operation on the slave side.
157 A user control command consists of a special
158 .Xr ioctl 2
159 operation with no data; the command is given as
160 .Dv UIOCCMD Ns (n) ,
161 where
162 .Ar n
163 is a number in the range 1-255.
164 The operation value
165 .Ar n
166 will be received as a single byte on the next
167 .Xr read 2
168 from the master side.
169 The
170 .Xr ioctl 2
171 .Dv UIOCCMD Ns (0)
172 is a no-op that may be used to probe for
173 the existence of this facility.
174 As with
175 .Dv TIOCPKT
176 mode, command operations may be detected with a
177 .Xr select 2
178 for exceptional conditions.
179 .El
180 .Pp
181 There is currently two
182 .Nm
183 systems available: the original
184 .Bx Nm ,
185 and a
186 SysVR4 pts-like implementation.
187 It is possible to switch between the two implementations by setting the
188 .Va kern.pts.enable
189 sysctl.
190 Setting it to 0 will use the
191 .Bx Nm ,
192 to non-zero the pts implementation.
193 It defaults to 0.
194 It is possible to set the maximum number of ptys
195 which can be allocated at the same time with the
196 .Va kern.pts.max
197 sysctl.
198 It defaults to 1000.
199 It is not recommended to use more than 1000 pseudo-terminals, as all software
200 which use
201 .Xr utmp 5
202 will not be able to handle pseudo-terminals with number superior to 999.
203 .Pp
204 The pts implementation also supports the
205 .Dv TIOCGPTN
206 .Xr ioctl 2
207 call, which takes a pointer to an
208 .Vt "unsigned int"
209 as a parameter and provides the
210 number of the pty.
211 .Sh FILES
212 The files used by the
213 .Bx
214 pseudo terminals implementation are:
215 .Pp
216 .Bl -tag -width ".Pa /dev/tty[p-sP-S][0-9a-v]" -compact
217 .It Pa /dev/pty[p-sP-S][0-9a-v]
218 master pseudo terminals
219 .It Pa /dev/tty[p-sP-S][0-9a-v]
220 slave pseudo terminals
221 .El
222 .Pp
223 The files used by the pts implementation are:
224 .Pp
225 .Bl -tag -width ".Pa /dev/pts/[num]" -compact
226 .It Pa /dev/ptmx
227 control device, returns a file descriptor to a new master pseudo terminal
228 when opened.
229 .It Pa /dev/pty[num]
230 master pseudo terminals
231 .It Pa /dev/pts/[num]
232 slave pseudo terminals
233 .El
234 .Sh DIAGNOSTICS
235 None.
236 .Sh SEE ALSO
237 .Xr tty 4
238 .Sh HISTORY
239 The
240 .Nm
241 driver appeared in
242 .Bx 4.2 .