1 .\" $NetBSD: pty.4,v 1.11 2006/10/06 22:07:44 elad Exp $
3 .\" Copyright (c) 1983, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)pty.4 8.2 (Berkeley) 11/30/93
37 .Nd pseudo terminal driver
39 .Cd pseudo-device pty Op Ar count
43 driver provides support for a device-pair termed a
45 A pseudo terminal is a pair of character devices, a
50 The slave device provides to a process an interface identical to
53 However, whereas all other devices which provide the interface described in
55 have a hardware device of some sort behind them, the slave device
56 has, instead, another process manipulating it through the master
57 half of the pseudo terminal.
58 That is, anything written on the master device is given to the
59 slave device as input and anything written on the slave device is
60 presented as input on the master device.
62 In configuring, if an optional
65 the specification, that number of pseudo terminal pairs is initially configured;
66 the default count is 16. Additional pseudo terminal pairs are allocated on
67 as-needed basis, maximum number of them is controlled via
69 sysctl (defaults to 992).
73 calls apply only to pseudo terminals:
74 .Bl -tag -width TIOCREMOTE
76 Stops output to a terminal (e.g. like typing
81 Restarts output (stopped by
90 Packet mode is enabled by specifying (by reference) a nonzero
91 parameter and disabled by specifying (by reference) a zero parameter.
92 When applied to the master side of a pseudo
93 terminal, each subsequent
95 from the terminal will return data written on the slave part of
96 the pseudo terminal preceded by a zero byte (symbolically
99 or a single byte reflecting control status information.
100 In the latter case, the byte is an inclusive-or
101 of zero or more of the bits:
102 .Bl -tag -width TIOCPKT_FLUSHWRITE
103 .It Dv TIOCPKT_FLUSHREAD
104 whenever the read queue for the terminal is flushed.
105 .It Dv TIOCPKT_FLUSHWRITE
106 whenever the write queue for the terminal is flushed.
108 whenever output to the terminal is stopped a la
111 whenever output to the terminal is restarted.
112 .It Dv TIOCPKT_DOSTOP
121 .It Dv TIOCPKT_NOSTOP
122 whenever the start and stop characters are not
125 While this mode is in use, the presence of control status information
126 to be read from the master side may be detected by a
128 for exceptional conditions.
134 to implement a remote-echoed, locally
137 remote login with proper back-flushing of output; it can be
138 used by other similar programs.
140 When this bit is set, the slave has changed the
142 structure (TTY state), and the remainder of the data read from
143 the master side of the
151 to implement TELNET "line mode" - it allows the
155 state changes by the slave, and negotiate the appropriate TELNET
156 protocol equivalents with the remote peer.
159 Enable/disable a mode that allows a small number of simple user
161 commands to be passed through the pseudo-terminal,
162 using a protocol similar to that of
168 modes are mutually exclusive.
169 This mode is enabled from the master side of a pseudo terminal
170 by specifying (by reference)
171 a nonzero parameter and disabled by specifying (by reference)
175 from the master side will return data written on the slave part of
176 the pseudo terminal preceded by a zero byte,
177 or a single byte reflecting a user control operation on the slave side.
178 A user control command consists of a special
180 operation with no data; the command is given as
184 is a number in the range 1-255.
187 will be received as a single byte on the next
189 from the master side.
193 is a no-op that may be used to probe for
194 the existence of this facility.
197 mode, command operations may be detected with a
199 for exceptional conditions.
201 A mode for the master half of a pseudo terminal, independent
204 This mode causes input to the pseudo terminal to be flow controlled
205 and not input edited (regardless of the terminal mode).
206 Each write to the control terminal produces a record boundary for
207 the process reading the terminal.
208 In normal usage, a write of data is like the data typed as a line
209 on the terminal; a write of 0 bytes is like typing an end-of-file
212 can be used when doing remote line
213 editing in a window manager, or whenever flow controlled input
217 .Bl -tag -width /dev/tty[p-zP-T][0-9a-zA-Z]x -compact
218 .It Pa /dev/pty[p-zP-T][0-9a-zA-Z]
219 master pseudo terminals
220 .It Pa /dev/tty[p-zP-T][0-9a-zA-Z]
221 slave pseudo terminals