xref: /illumos-gate/usr/src/man/man4d/pty.4d (revision 50959a0eb0e3bc8618e60f532f23b93bfc7bcad7)
1bbf21555SRichard Lowe'\" te
2bbf21555SRichard Lowe.\" Copyright (c) 1994, Sun Microsystems, Inc.
3bbf21555SRichard Lowe.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4bbf21555SRichard Lowe.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5bbf21555SRichard Lowe.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6bbf21555SRichard Lowe.\" Copyright 2022 Oxide Computer Company
7*50959a0eSMike Zeller.Dd August 19, 2022
8bbf21555SRichard Lowe.Dt PTY 4D
9bbf21555SRichard Lowe.Os
10bbf21555SRichard Lowe.Sh NAME
11bbf21555SRichard Lowe.Nm pty
12bbf21555SRichard Lowe.Nd legacy pseudo-terminal driver
13bbf21555SRichard Lowe.Sh SYNOPSIS
14bbf21555SRichard Lowe.Pa /dev/pty[p-r]*
15bbf21555SRichard Lowe.Pp
16bbf21555SRichard Lowe.Pa /dev/tty[p-r]*
17bbf21555SRichard Lowe.Sh DESCRIPTION
18bbf21555SRichard LoweThis driver provides support for legacy static pseudo-terminal devices.
19bbf21555SRichard LoweModern software does not use this driver, preferring instead the STREAMS-based
20bbf21555SRichard Lowe.Xr ptm 4D
21bbf21555SRichard Loweand
22bbf21555SRichard Lowe.Xr pts 4D
23bbf21555SRichard Lowepseudo-terminal drivers, consumed through the portable
24bbf21555SRichard Lowe.Xr posix_openpt 3C
25bbf21555SRichard Loweinterface.
26bbf21555SRichard Lowe.Pp
27bbf21555SRichard LoweThe
28bbf21555SRichard Lowe.Nm pty
29bbf21555SRichard Lowedriver provides support for a pair of devices collectively known
30bbf21555SRichard Loweas a
31bbf21555SRichard Lowe.Em pseudo-terminal .
32bbf21555SRichard LoweThe two devices comprising a pseudo-terminal are known as a
33bbf21555SRichard Lowe.Em manager
34bbf21555SRichard Loweand a
35bbf21555SRichard Lowe.Em subsidiary .
36bbf21555SRichard LoweThe subsidiary device distinguishes between the
37bbf21555SRichard Lowe.Dv B0 baud rate and other baud rates specified in
38bbf21555SRichard Lowethe
39bbf21555SRichard Lowe.Fa c_cflag
40bbf21555SRichard Lowefield of the
41bbf21555SRichard Lowe.Vt termios
42bbf21555SRichard Lowestructure, and the
43bbf21555SRichard Lowe.Dv CLOCAL
44bbf21555SRichard Loweflag in that member.
45bbf21555SRichard LoweIt does not support any of the other
46bbf21555SRichard Lowe.Xr termio 4I
47bbf21555SRichard Lowedevice control functions specified by flags in the
48bbf21555SRichard Lowe.Fa c_cflag
49bbf21555SRichard Lowefield of the
50bbf21555SRichard Lowe.Vt termios
51bbf21555SRichard Lowestructure and by the
52bbf21555SRichard Lowe.Dv IGNBRK ,
53bbf21555SRichard Lowe.Dv IGNPAR ,
54bbf21555SRichard Lowe.Dv PARMRK ,
55bbf21555SRichard Loweor
56bbf21555SRichard Lowe.Dv INPCK
57bbf21555SRichard Loweflags in the
58bbf21555SRichard Lowe.Fa c_iflag
59bbf21555SRichard Lowefield of the
60bbf21555SRichard Lowe.Vt termios
61bbf21555SRichard Lowestructure, as these functions apply only to asynchronous serial ports.
62bbf21555SRichard LoweAll other
63bbf21555SRichard Lowe.Xr termio 4I
64bbf21555SRichard Lowefunctions must be performed by STREAMS modules pushed atop the driver; when a
65bbf21555SRichard Lowesubsidiary device is opened, the
66bbf21555SRichard Lowe.Xr ldterm 4M
67bbf21555SRichard Loweand
68bbf21555SRichard Lowe.Xr ttcompat 4M
69bbf21555SRichard LoweSTREAMS modules are automatically pushed on top of the stream, providing the
70bbf21555SRichard Lowestandard
71bbf21555SRichard Lowe.Xr termio 4I
72bbf21555SRichard Loweinterface.
73bbf21555SRichard Lowe.Pp
74bbf21555SRichard LoweInstead of having a hardware interface and associated hardware that supports
75bbf21555SRichard Lowethe terminal functions, the functions are implemented by another process
76bbf21555SRichard Lowemanipulating the manager device of the pseudo-terminal.
77bbf21555SRichard Lowe.Pp
78bbf21555SRichard LoweThe manager and the subsidiary devices of the pseudo-terminal are tightly
79bbf21555SRichard Loweconnected.
80bbf21555SRichard LoweAny data written on the manager device is given to the subsidiary device as
81bbf21555SRichard Loweinput, as though it had been received from a hardware interface.
82bbf21555SRichard LoweAny data written on the subsidiary terminal can be read from the manager device
83bbf21555SRichard Lowe.Pq "rather than being transmitted from a UAR" .
84bbf21555SRichard Lowe.Pp
85bbf21555SRichard LoweThe driver is statically configured to provide 48 pseudo-terminal pairs.
86bbf21555SRichard LoweSoftware that requires dynamic pseudo-terminal devices, or a greater number
87bbf21555SRichard Loweof devices, must be converted to use
88bbf21555SRichard Lowe.Xr ptm 4D .
89bbf21555SRichard Lowe.Sh IOCTLS
90bbf21555SRichard LoweThe standard set of
91bbf21555SRichard Lowe.Xr termio 4I
92bbf21555SRichard Loweioctls are supported by the subsidiary device.
93bbf21555SRichard LoweNone of the bits in the
94bbf21555SRichard Lowe.Fa c_cflag
95bbf21555SRichard Lowefield have any effect on the pseudo-terminal, except that if the baud rate is
96bbf21555SRichard Loweset to
97bbf21555SRichard Lowe.Dv B0 ,
98bbf21555SRichard Loweit will appear to the process on the manager device as if the last process on
99bbf21555SRichard Lowethe subsidiary device had closed the line; thus, setting the baud rate to
100bbf21555SRichard Lowe.Dv B0
101bbf21555SRichard Lowehas the effect of
102bbf21555SRichard Lowe.Dq hanging up
103bbf21555SRichard Lowethe pseudo-terminal, just as it has the effect of
104bbf21555SRichard Lowe.Dq hanging up
105bbf21555SRichard Lowea real terminal.
106bbf21555SRichard Lowe.Pp
107bbf21555SRichard LoweThere is no notion of
108bbf21555SRichard Lowe.Dq parity
109bbf21555SRichard Loweon a pseudo-terminal, so none of the flags in the
110bbf21555SRichard Lowe.Fa c_iflag
111bbf21555SRichard Lowefield that control the processing of parity errors have any
112bbf21555SRichard Loweeffect.
113bbf21555SRichard LoweSimilarly, there is no notion of a
114bbf21555SRichard Lowe.Fa break ,
115bbf21555SRichard Loweso none of the flags that control the processing of breaks, and none of the
116bbf21555SRichard Loweioctls that generate breaks, have any effect.
117bbf21555SRichard Lowe.Pp
118bbf21555SRichard LoweInput flow control is automatically performed; a process that attempts to write
119bbf21555SRichard Loweto the manager device will be blocked if too much unconsumed data is buffered
120bbf21555SRichard Loweon the subsidiary device.
121bbf21555SRichard LoweThe input flow control provided by the
122bbf21555SRichard Lowe.Dv IXOFF
123bbf21555SRichard Loweflag in the
124bbf21555SRichard Lowe.Fa c_iflag
125bbf21555SRichard Lowefield is not supported.
126bbf21555SRichard Lowe.Pp
127bbf21555SRichard LoweThe delays specified in the
128bbf21555SRichard Lowe.Fa c_oflag
129bbf21555SRichard Lowefield are not supported.
130bbf21555SRichard Lowe.Pp
131bbf21555SRichard LoweAs there are no modems involved in a pseudo-terminal, the ioctls that return or
132bbf21555SRichard Lowealter the state of modem control lines are silently ignored.
133bbf21555SRichard Lowe.Pp
134bbf21555SRichard LoweA few special ioctls are provided on the manager devices of pseudo-terminals to
135bbf21555SRichard Loweprovide the functionality needed by applications programs to emulate real
136bbf21555SRichard Lowehardware interfaces:
137bbf21555SRichard Lowe.Bl -tag -width Ds
138bbf21555SRichard Lowe.It Dv TIOCSTOP
139bbf21555SRichard LoweThe argument is ignored.
140bbf21555SRichard LoweOutput to the pseudo-terminal is suspended, as if a
141bbf21555SRichard Lowe.Sy STOP
142bbf21555SRichard Lowecharacter had been typed.
143bbf21555SRichard Lowe.It Dv TIOCSTART
144bbf21555SRichard LoweThe argument is ignored.
145bbf21555SRichard LoweOutput to the pseudo-terminal is restarted, as if a
146bbf21555SRichard Lowe.Sy START
147bbf21555SRichard Lowecharacter had been typed.
148bbf21555SRichard Lowe.It Dv TIOCPKT
149bbf21555SRichard LoweThe argument is a pointer to an
150bbf21555SRichard Lowe.Vt int .
151bbf21555SRichard LoweIf the value of the
152bbf21555SRichard Lowe.Vt int
153bbf21555SRichard Loweis non-zero,
154bbf21555SRichard Lowe.Em packet
155bbf21555SRichard Lowemode is enabled; if the value of the
156bbf21555SRichard Lowe.Vt int
157bbf21555SRichard Loweis zero, packet mode is disabled.
158bbf21555SRichard LoweWhen a pseudo-terminal is in packet mode, each subsequent
159bbf21555SRichard Lowe.Xr read 2
160bbf21555SRichard Lowefrom the manager device will return data written on the subsidiary device
161bbf21555SRichard Lowepreceded by a zero byte
162bbf21555SRichard Lowe.Po
163bbf21555SRichard Lowesymbolically defined as
164bbf21555SRichard Lowe.Dv TIOCPKT_DATA
165bbf21555SRichard Lowe.Pc ,
166bbf21555SRichard Loweor a single byte reflecting control status information.
167bbf21555SRichard LoweIn the latter case, the byte is an inclusive-or of zero or more of the bits:
168bbf21555SRichard Lowe.Bl -tag -width Ds
169bbf21555SRichard Lowe.It Dv TIOCPKT_FLUSHREAD
170bbf21555SRichard LoweWhenever the read queue for the terminal is flushed.
171bbf21555SRichard Lowe.It Dv TIOCPKT_FLUSHWRITE
172bbf21555SRichard LoweWhenever the write queue for the terminal is flushed.
173bbf21555SRichard Lowe.It Dv TIOCPKT_STOP
174bbf21555SRichard LoweWhenever output to the terminal is stopped using
175bbf21555SRichard Lowe.Sy ^S .
176bbf21555SRichard Lowe.It Dv TIOCPKT_START
177bbf21555SRichard LoweWhenever output to the terminal is restarted.
178bbf21555SRichard Lowe.It Dv TIOCPKT_DOSTOP
179bbf21555SRichard LoweWhenever
180bbf21555SRichard Lowe.Em XON/XOFF
181bbf21555SRichard Loweflow control is enabled after being disabled; it is
182bbf21555SRichard Loweconsidered
183bbf21555SRichard Lowe.Dq enabled
184bbf21555SRichard Lowewhen the
185bbf21555SRichard Lowe.Dv IXON
186bbf21555SRichard Loweflag in the
187bbf21555SRichard Lowe.Fa c_iflag
188bbf21555SRichard Lowefield is set, the
189bbf21555SRichard Lowe.Dv VSTOP
190bbf21555SRichard Lowemember of the
191bbf21555SRichard Lowe.Fa c_cc
192bbf21555SRichard Lowearray is
193bbf21555SRichard Lowe.Sy ^S
194bbf21555SRichard Loweand the
195bbf21555SRichard Lowe.Dv VSTART
196bbf21555SRichard Lowemember of the
197bbf21555SRichard Lowe.Fa c_cc
198bbf21555SRichard Lowearray is
199bbf21555SRichard Lowe.Sy ^Q.
200bbf21555SRichard Lowe.It Dv TIOCPKT_NOSTOP
201bbf21555SRichard LoweWhenever
202bbf21555SRichard Lowe.Em XON/XOFF
203bbf21555SRichard Loweflow control is disabled after being enabled.
204bbf21555SRichard Lowe.El
205bbf21555SRichard Lowe.It Dv TIOCREMOTE
206bbf21555SRichard LoweThe argument is a pointer to an
207bbf21555SRichard Lowe.Vt int .
208bbf21555SRichard LoweIf the value of the
209bbf21555SRichard Lowe.Vt int
210bbf21555SRichard Loweis non-zero,
211bbf21555SRichard Lowe.Em remote
212bbf21555SRichard Lowemode is enabled; if the value of the
213bbf21555SRichard Lowe.Vt int
214bbf21555SRichard Loweis zero, remote mode is disabled.
215bbf21555SRichard LoweThis mode can be enabled or disabled independently of packet mode.
216bbf21555SRichard LoweWhen a pseudo-terminal is in remote mode, input to the subsidiary device of the
217bbf21555SRichard Lowepseudo-terminal is flow controlled and not input edited (regardless of the mode
218bbf21555SRichard Lowethe subsidiary side of the pseudo-terminal).
219bbf21555SRichard Lowe.Pp
220bbf21555SRichard LoweEach write to the manager device produces a record boundary for the process
221bbf21555SRichard Lowereading the subsidiary device.
222bbf21555SRichard LoweIn normal usage, a write of data is like the data typed as a line on the
223bbf21555SRichard Loweterminal; a write of 0 bytes is like typing an
224bbf21555SRichard Lowe.Sy EOF
225bbf21555SRichard Lowecharacter.
226bbf21555SRichard LoweNote: this means that a process writing to a pseudo-terminal manager in remote
227bbf21555SRichard Lowemode must keep track of line boundaries, and write only one line at a time to
228bbf21555SRichard Lowethe manager.
229bbf21555SRichard Lowe.Pp
230bbf21555SRichard LoweIf, for example, it were to buffer up several newline characters and write them
231bbf21555SRichard Loweto the manager with one
232bbf21555SRichard Lowe.Xr write 2 ,
233bbf21555SRichard Loweit would appear to a process reading from the subsidiary as if a single line
234bbf21555SRichard Lowecontaining several newline characters had been typed
235bbf21555SRichard Lowe.Po
236bbf21555SRichard Loweas if, for example, a user had typed the literal next
237bbf21555SRichard Lowe.Pq Sy LNEXT
238bbf21555SRichard Lowecharacter before typing all but the last of those newline characters
239bbf21555SRichard Lowe.Pc .
240bbf21555SRichard LoweRemote mode can be used when doing remote line editing in a window manager, or
241bbf21555SRichard Lowewhenever flow controlled input is required.
242bbf21555SRichard Lowe.El
243bbf21555SRichard Lowe.Sh FILES
244bbf21555SRichard Lowe.Bl -tag -width Pa
245bbf21555SRichard Lowe.It Pa /dev/pty[p-r][0-9a-f]
246bbf21555SRichard LowePseudo-terminal manager devices.
247bbf21555SRichard Lowe.It Pa /dev/tty[p-r][0-9a-f]
248bbf21555SRichard LowePseudo-terminal subsidiary devices.
249bbf21555SRichard Lowe.El
250bbf21555SRichard Lowe.Sh SEE ALSO
251bbf21555SRichard Lowe.Xr rlogin 1 ,
252*50959a0eSMike Zeller.Xr posix_openpt 3C ,
253bbf21555SRichard Lowe.Xr ptm 4D ,
254bbf21555SRichard Lowe.Xr termio 4I ,
255bbf21555SRichard Lowe.Xr ldterm 4M ,
256bbf21555SRichard Lowe.Xr ttcompat 4M ,
257bbf21555SRichard Lowe.Xr rlogind 8
258bbf21555SRichard Lowe.Sh NOTES
259bbf21555SRichard LoweThis is a legacy device and should not be used by new software.
260bbf21555SRichard Lowe.Pp
261bbf21555SRichard LoweIt is apparently not possible to send an
262bbf21555SRichard Lowe.Sy EOT
263bbf21555SRichard Loweby writing zero bytes in
264bbf21555SRichard Lowe.Dv TIOCREMOTE
265bbf21555SRichard Lowemode.
266