xref: /openbsd/share/man/man4/pty.4 (revision df930be7)
1.\"	$NetBSD: pty.4,v 1.3 1994/11/30 16:22:30 jtc Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
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. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)pty.4	8.2 (Berkeley) 11/30/93
35.\"
36.Dd November 30, 1993
37.Dt PTY 4
38.Os BSD 4.2
39.Sh NAME
40.Nm pty
41.Nd pseudo terminal driver
42.Sh SYNOPSIS
43.Nm pseudo-device pty
44.Op Ar count
45.Sh DESCRIPTION
46The
47.Xr pty
48driver provides support for a device-pair termed a
49.Em pseudo terminal .
50A pseudo terminal is a pair of character devices, a
51.Em master
52device and a
53.Em slave
54device.  The slave device provides to a process
55an interface identical
56to that described in
57.Xr tty 4 .
58However, whereas all other devices which provide the
59interface described in
60.Xr tty 4
61have a hardware device of some sort behind them, the slave
62device has, instead, another process manipulating
63it through the master half of the pseudo terminal.
64That is, anything written on the master device is
65given to the slave device as input and anything written
66on the slave device is presented as input on the master
67device.
68.Pp
69In configuring, if an optional
70.Ar count
71is given in
72the specification, that number of pseudo terminal pairs are configured;
73the default count is 32.
74.Pp
75The following
76.Xr ioctl 2
77calls apply only to pseudo terminals:
78.Bl -tag -width TIOCREMOTE
79.It Dv TIOCSTOP
80Stops output to a terminal (e.g. like typing
81.Ql ^S ) .
82Takes
83no parameter.
84.It Dv TIOCSTART
85Restarts output (stopped by
86.Dv TIOCSTOP
87or by typing
88.Ql ^S ) .
89Takes no parameter.
90.It Dv TIOCPKT
91Enable/disable
92.Em packet
93mode.  Packet mode is enabled by specifying (by reference)
94a nonzero parameter and disabled by specifying (by reference)
95a zero parameter.  When applied to the master side of a pseudo
96terminal, each subsequent
97.Xr read
98from the terminal will return data written on the slave part of
99the pseudo terminal preceded by a zero byte (symbolically
100defined as
101.Dv TIOCPKT_DATA ) ,
102or a single byte reflecting control
103status information.  In the latter case, the byte is an inclusive-or
104of zero or more of the bits:
105.Bl -tag -width TIOCPKT_FLUSHWRITE
106.It Dv TIOCPKT_FLUSHREAD
107whenever the read queue for the terminal is flushed.
108.It Dv TIOCPKT_FLUSHWRITE
109whenever the write queue for the terminal is flushed.
110.It Dv TIOCPKT_STOP
111whenever output to the terminal is stopped a la
112.Ql ^S .
113.It Dv TIOCPKT_START
114whenever output to the terminal is restarted.
115.It Dv TIOCPKT_DOSTOP
116whenever
117.Em t_stopc
118is
119.Ql ^S
120and
121.Em t_startc
122is
123.Ql ^Q .
124.It Dv TIOCPKT_NOSTOP
125whenever the start and stop characters are not
126.Ql ^S/^Q .
127.Pp
128While this mode is in use, the presence of control status information
129to be read from the master side may be detected by a
130.Xr select 2
131for exceptional conditions.
132.Pp
133This mode is used by
134.Xr rlogin 1
135and
136.Xr rlogind 8
137to implement a remote-echoed, locally
138.Ql ^S/^Q
139flow-controlled
140remote login with proper back-flushing of output; it can be
141used by other similar programs.
142.El
143.It Dv TIOCUCNTL
144Enable/disable a mode that allows a small number of simple user
145.Xr ioctl
146commands to be passed through the pseudo-terminal,
147using a protocol similar to that of
148.Dv TIOCPKT .
149The
150.Dv TIOCUCNTL
151and
152.Dv TIOCPKT
153modes are mutually exclusive.
154This mode is enabled from the master side of a pseudo terminal
155by specifying (by reference)
156a nonzero parameter and disabled by specifying (by reference)
157a zero parameter.
158Each subsequent
159.Xr read
160from the master side will return data written on the slave part of
161the pseudo terminal preceded by a zero byte,
162or a single byte reflecting a user control operation on the slave side.
163A user control command consists of a special
164.Xr ioctl
165operation with no data; the command is given as
166.Dv UIOCCMD Ns (n) ,
167where
168.Ar n
169is a number in the range 1-255.
170The operation value
171.Ar n
172will be received as a single byte on the next
173.Xr read
174from the master side.
175The
176.Xr ioctl
177.Dv UIOCCMD Ns (0)
178is a no-op that may be used to probe for
179the existence of this facility.
180As with
181.Dv TIOCPKT
182mode, command operations may be detected with a
183.Xr select
184for exceptional conditions.
185.It Dv TIOCREMOTE
186A mode for the master half of a pseudo terminal, independent
187of
188.Dv TIOCPKT .
189This mode causes input to the pseudo terminal
190to be flow controlled and not input edited (regardless of the
191terminal mode).  Each write to the control terminal produces
192a record boundary for the process reading the terminal.  In
193normal usage, a write of data is like the data typed as a line
194on the terminal; a write of 0 bytes is like typing an end-of-file
195character.
196.Dv TIOCREMOTE
197can be used when doing remote line
198editing in a window manager, or whenever flow controlled input
199is required.
200.El
201.Sh FILES
202.Bl -tag -width /dev/tty[p-r][0-9a-f]x -compact
203.It Pa /dev/pty[p-r][0-9a-f]
204master pseudo terminals
205.It Pa /dev/tty[p-r][0-9a-f]
206slave pseudo terminals
207.El
208.Sh DIAGNOSTICS
209None.
210.Sh HISTORY
211The
212.Nm
213driver appeared in
214.Bx 4.2 .
215