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