date and time created 88/06/13 15:09:44 by mckusick
[unix-history] / usr / src / share / man / man4 / pty.4
CommitLineData
16b5b9ce
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
16a51b60 5.\" @(#)pty.4 6.2 (Berkeley) %G%
16b5b9ce 6.\"
260e89d5 7.TH PTY 4 ""
16b5b9ce
KM
8.UC 5
9.SH NAME
10pty \- pseudo terminal driver
11.SH SYNOPSIS
16a51b60 12.B pseudo-device pty [ count ]
16b5b9ce
KM
13.SH DESCRIPTION
14The
15.I pty
16driver provides support for a device-pair termed a
17.IR "pseudo terminal" .
18A pseudo terminal is a pair of character devices, a
19.I master
20device and a
21.I slave
22device. The slave device provides processes
23an interface identical
24to that described in
25.IR tty (4).
26However, whereas all other devices which provide the
27interface described in
28.IR tty (4)
29have a hardware device of some sort behind them, the slave
30device has, instead, another process manipulating
31it through the master half of the pseudo terminal.
32That is, anything written on the master device is
33given to the slave device as input and anything written
34on the slave device is presented as input on the master
35device.
36.PP
16a51b60
MK
37In configuring, if an optional ``count'' is given in
38the specification, that number of pseudo terminal pairs are configured;
39the default count is 32.
16b5b9ce
KM
40.PP
41The following
42.I ioctl
43calls apply only to pseudo terminals:
44.TP
45TIOCSTOP
46Stops output to a terminal (e.g. like typing ^S). Takes
47no parameter.
48.TP
49TIOCSTART
50Restarts output (stopped by TIOCSTOP or by typing ^S).
51Takes no parameter.
52.TP
53TIOCPKT
54Enable/disable
55.I packet
56mode. Packet mode is enabled by specifying (by reference)
57a nonzero parameter and disabled by specifying (by reference)
58a zero parameter. When applied to the master side of a pseudo
59terminal, each subsequent
60.I read
61from the terminal will return data written on the slave part of
62the pseudo terminal preceded by a zero byte (symbolically
63defined as TIOCPKT_DATA), or a single byte reflecting control
64status information. In the latter case, the byte is an inclusive-or
65of zero or more of the bits:
66.RS
67.TP
68TIOCPKT_FLUSHREAD
69whenever the read queue for the terminal is flushed.
70.TP
71TIOCPKT_FLUSHWRITE
72whenever the write queue for the terminal is flushed.
73.TP
74TIOCPKT_STOP
75whenever output to the terminal is stopped a la ^S.
76.TP
77TIOCPKT_START
78whenever output to the terminal is restarted.
79.TP
80TIOCPKT_DOSTOP
81whenever
82.I t_stopc
83is ^S
84and
85.I t_startc
86is ^Q.
87.TP
88TIOCPKT_NOSTOP
89whenever the start and stop characters are not ^S/^Q.
90.RE
91.IP
16a51b60
MK
92While this mode is in use, the presence of control status information
93to be read from the master side may be detected by a
94.I select
95for exceptional conditions.
96.IP
16b5b9ce
KM
97This mode is used by
98.IR rlogin (1C)
99and
100.IR rlogind (8C)
101to implement a remote-echoed, locally ^S/^Q flow-controlled
102remote login with proper back-flushing of output; it can be
103used by other similar programs.
104.TP
16a51b60
MK
105TIOCUCNTL
106Enable/disable a mode that allows a small number of simple user
107.I ioctl
108commands to be passed through the pseudo-terminal,
109using a protocol similar to that of TIOCPKT.
110The TIOCUCNTL and TIOCPKT modes are mutually exclusive.
111This mode is enabled from the master side of a pseudo terminal
112by specifying (by reference)
113a nonzero parameter and disabled by specifying (by reference)
114a zero parameter.
115Each subsequent
116.I read
117from the master side will return data written on the slave part of
118the pseudo terminal preceded by a zero byte,
119or a single byte reflecting a user control operation on the slave side.
120A user control command consists of a special
121.I ioctl
122operation with no data; the command is given as UIOCCMD(\fIn\fP),
123where \fIn\fP is a number in the range 1-255.
124The operation value \fIn\fP will be received as a single byte on the next
125.I read
126from the master side.
127The \fIioctl\fP UIOCCMD(0) is a no-op that may be used to probe for
128the existence of this facility.
129As with TIOCPKT mode, command operations may be detected with a
130.I select
131for exceptional conditions.
132.TP
16b5b9ce
KM
133TIOCREMOTE
134A mode for the master half of a pseudo terminal, independent
135of TIOCPKT. This mode causes input to the pseudo terminal
136to be flow controlled and not input edited (regardless of the
137terminal mode). Each write to the control terminal produces
138a record boundary for the process reading the terminal. In
139normal usage, a write of data is like the data typed as a line
140on the terminal; a write of 0 bytes is like typing an end-of-file
141character. TIOCREMOTE can be used when doing remote line
142editing in a window manager, or whenever flow controlled input
143is required.
144.SH FILES
145.DT
146/dev/pty[p-r][0-9a-f] master pseudo terminals
147.br
148/dev/tty[p-r][0-9a-f] slave pseudo terminals
149.SH DIAGNOSTICS
150None.