xref: /386bsd/usr/src/kernel/pty/pty.4 (revision a2142627)
1.\" Copyright (c) 1983, 1991 Regents of the University of California.
2.\" 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.\"     $Id$
33.\"
34.Dd March 28, 1991
35.Dt PTY 4
36.Os BSD 4.2
37.Sh NAME
38.Nm pty
39.Nd pseudo terminal driver
40.Sh SYNOPSIS
41.Nm pty slave_chr_major control_chr_major
42.Op Ar ptycount .
43.Sh DESCRIPTION
44The
45.Xr pty
46driver provides support for a device-pair termed a
47.Em pseudo terminal .
48A pseudo terminal is a pair of character devices, a
49.Em master
50device and a
51.Em slave
52device.  The slave device provides processes
53an interface identical
54to that described in
55.Xr tty 4 .
56However, whereas all other devices which provide the
57interface described in
58.Xr tty 4
59have a hardware device of some sort behind them, the slave
60device has, instead, another process manipulating
61it through the master half of the pseudo terminal.
62That is, anything written on the master device is
63given to the slave device as input and anything written
64on the slave device is presented as input on the master
65device.
66.Pp
67If an optional
68.Ar count
69is given in
70the device configuration specification,
71that number of pseudo terminal pairs are configured;
72the default count is 8.
73.Pp
74The following
75.Xr ioctl 2
76calls apply only to pseudo terminals:
77.Bl -tag -width TIOCREMOTE
78.It Dv TIOCSTOP
79Stops output to a terminal (e.g. like typing
80.Ql ^S ) .
81Takes
82no parameter.
83.It Dv TIOCSTART
84Restarts output (stopped by
85.Dv TIOCSTOP
86or by typing
87.Ql ^S ) .
88Takes no parameter.
89.It Dv TIOCPKT
90Enable/disable
91.Em packet
92mode.  Packet mode is enabled by specifying (by reference)
93a nonzero parameter and disabled by specifying (by reference)
94a zero parameter.  When applied to the master side of a pseudo
95terminal, each subsequent
96.Xr read
97from the terminal will return data written on the slave part of
98the pseudo terminal preceded by a zero byte (symbolically
99defined as
100.Dv TIOCPKT_DATA ) ,
101or a single byte reflecting control
102status information.  In the latter case, the byte is an inclusive-or
103of zero or more of the bits:
104.Bl -tag -width TIOCPKT_FLUSHWRITE
105.It Dv TIOCPKT_FLUSHREAD
106whenever the read queue for the terminal is flushed.
107.It Dv TIOCPKT_FLUSHWRITE
108whenever the write queue for the terminal is flushed.
109.It Dv TIOCPKT_STOP
110whenever output to the terminal is stopped a la
111.Ql ^S .
112.It Dv TIOCPKT_START
113whenever output to the terminal is restarted.
114.It Dv TIOCPKT_DOSTOP
115whenever
116.Em t_stopc
117is
118.Ql ^S
119and
120.Em t_startc
121is
122.Ql ^Q .
123.It Dv TIOCPKT_NOSTOP
124whenever the start and stop characters are not
125.Ql ^S/^Q .
126.Pp
127While this mode is in use, the presence of control status information
128to be read from the master side may be detected by a
129.Xr select 2
130for exceptional conditions.
131.Pp
132This mode is used by
133.Xr rlogin 1
134and
135.Xr rlogind 8
136to implement a remote-echoed, locally
137.Ql ^S/^Q
138flow-controlled
139remote login with proper back-flushing of output; it can be
140used by other similar programs.
141.El
142.It Dv TIOCUCNTL
143Enable/disable a mode that allows a small number of simple user
144.Xr ioctl
145commands to be passed through the pseudo-terminal,
146using a protocol similar to that of
147.Dv TIOCPKT .
148The
149.Dv TIOCUCNTL
150and
151.Dv TIOCPKT
152modes are mutually exclusive.
153This mode is enabled from the master side of a pseudo terminal
154by specifying (by reference)
155a nonzero parameter and disabled by specifying (by reference)
156a zero parameter.
157Each subsequent
158.Xr read
159from the master side will return data written on the slave part of
160the pseudo terminal preceded by a zero byte,
161or a single byte reflecting a user control operation on the slave side.
162A user control command consists of a special
163.Xr ioctl
164operation with no data; the command is given as
165.Dv UIOCCMD Ns (n) ,
166where
167.Ar n
168is a number in the range 1-255.
169The operation value
170.Ar n
171will be received as a single byte on the next
172.Xr read
173from the master side.
174The
175.Xr ioctl
176.Dv UIOCCMD Ns (0)
177is a no-op that may be used to probe for
178the existence of this facility.
179As with
180.Dv TIOCPKT
181mode, command operations may be detected with a
182.Xr select
183for exceptional conditions.
184.It Dv TIOCREMOTE
185A mode for the master half of a pseudo terminal, independent
186of
187.Dv TIOCPKT .
188This mode causes input to the pseudo terminal
189to be flow controlled and not input edited (regardless of the
190terminal mode).  Each write to the control terminal produces
191a record boundary for the process reading the terminal.  In
192normal usage, a write of data is like the data typed as a line
193on the terminal; a write of 0 bytes is like typing an end-of-file
194character.
195.Dv TIOCREMOTE
196can be used when doing remote line
197editing in a window manager, or whenever flow controlled input
198is required.
199.El
200.Sh FILES
201.Bl -tag -width /dev/tty[p-r][0-9a-f]x -compact
202.It Pa /dev/pty[p-r][0-9a-f]
203master pseudo terminals
204.It Pa /dev/tty[p-r][0-9a-f]
205slave pseudo terminals
206.El
207.Sh DIAGNOSTICS
208None.
209.Sh HISTORY
210The
211.Nm
212driver appeared in
213.Bx 4.2 .
214