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