1*47675Scael.\" Copyright (c) 1983, 1991 Regents of the University of California. 2*47675Scael.\" All rights reserved. 320740Smckusick.\" 4*47675Scael.\" %sccs.include.redist.man% 520740Smckusick.\" 6*47675Scael.\" @(#)pty.4 6.3 (Berkeley) 03/28/91 7*47675Scael.\" 8*47675Scael.Dd 9*47675Scael.Dt PTY 4 10*47675Scael.Os BSD 4.2 11*47675Scael.Sh NAME 12*47675Scael.Nm pty 13*47675Scael.Nd pseudo terminal driver 14*47675Scael.Sh SYNOPSIS 15*47675Scael.Nm pseudo-device pty 16*47675Scael.Op Ar count 17*47675Scael.Sh DESCRIPTION 1820740SmckusickThe 19*47675Scael.Xr pty 2020740Smckusickdriver provides support for a device-pair termed a 21*47675Scael.Em pseudo terminal . 2220740SmckusickA pseudo terminal is a pair of character devices, a 23*47675Scael.Em master 2420740Smckusickdevice and a 25*47675Scael.Em slave 2620740Smckusickdevice. The slave device provides processes 2720740Smckusickan interface identical 2820740Smckusickto that described in 29*47675Scael.Xr tty 4 . 3020740SmckusickHowever, whereas all other devices which provide the 3120740Smckusickinterface described in 32*47675Scael.Xr tty 4 3320740Smckusickhave a hardware device of some sort behind them, the slave 3420740Smckusickdevice has, instead, another process manipulating 3520740Smckusickit through the master half of the pseudo terminal. 3620740SmckusickThat is, anything written on the master device is 3720740Smckusickgiven to the slave device as input and anything written 3820740Smckusickon the slave device is presented as input on the master 3920740Smckusickdevice. 40*47675Scael.Pp 41*47675ScaelIn configuring, if an optional 42*47675Scael.Ar count 43*47675Scaelis given in 4428289Skarelsthe specification, that number of pseudo terminal pairs are configured; 4528289Skarelsthe default count is 32. 46*47675Scael.Pp 4720740SmckusickThe following 48*47675Scael.Xr ioctl 2 4920740Smckusickcalls apply only to pseudo terminals: 50*47675Scael.Bl -tag -width TIOCREMOTE 51*47675Scael.It Dv TIOCSTOP 52*47675ScaelStops output to a terminal (e.g. like typing 53*47675Scael.Ql ^S ) . 54*47675ScaelTakes 5520740Smckusickno parameter. 56*47675Scael.It Dv TIOCSTART 57*47675ScaelRestarts output (stopped by 58*47675Scael.Dv TIOCSTOP 59*47675Scaelor by typing 60*47675Scael.Ql ^S ) . 6120740SmckusickTakes no parameter. 62*47675Scael.It Dv TIOCPKT 6320740SmckusickEnable/disable 64*47675Scael.Em packet 6520740Smckusickmode. Packet mode is enabled by specifying (by reference) 6620740Smckusicka nonzero parameter and disabled by specifying (by reference) 6720740Smckusicka zero parameter. When applied to the master side of a pseudo 6820740Smckusickterminal, each subsequent 69*47675Scael.Xr read 7020740Smckusickfrom the terminal will return data written on the slave part of 7120740Smckusickthe pseudo terminal preceded by a zero byte (symbolically 72*47675Scaeldefined as 73*47675Scael.Dv TIOCPKT_DATA ) , 74*47675Scaelor a single byte reflecting control 7520740Smckusickstatus information. In the latter case, the byte is an inclusive-or 7620740Smckusickof zero or more of the bits: 77*47675Scael.Bl -tag -width TIOCPKT_FLUSHWRITE 78*47675Scael.It Dv TIOCPKT_FLUSHREAD 7920740Smckusickwhenever the read queue for the terminal is flushed. 80*47675Scael.It Dv TIOCPKT_FLUSHWRITE 8120740Smckusickwhenever the write queue for the terminal is flushed. 82*47675Scael.It Dv TIOCPKT_STOP 83*47675Scaelwhenever output to the terminal is stopped a la 84*47675Scael.Ql ^S . 85*47675Scael.It Dv TIOCPKT_START 8620740Smckusickwhenever output to the terminal is restarted. 87*47675Scael.It Dv TIOCPKT_DOSTOP 8820740Smckusickwhenever 89*47675Scael.Em t_stopc 90*47675Scaelis 91*47675Scael.Ql ^S 9220740Smckusickand 93*47675Scael.Em t_startc 94*47675Scaelis 95*47675Scael.Ql ^Q . 96*47675Scael.It Dv TIOCPKT_NOSTOP 97*47675Scaelwhenever the start and stop characters are not 98*47675Scael.Ql ^S/^Q . 99*47675Scael.Pp 10028289SkarelsWhile this mode is in use, the presence of control status information 10128289Skarelsto be read from the master side may be detected by a 102*47675Scael.Xr select 2 10328289Skarelsfor exceptional conditions. 104*47675Scael.Pp 10520740SmckusickThis mode is used by 106*47675Scael.Xr rlogin 1 10720740Smckusickand 108*47675Scael.Xr rlogind 8 109*47675Scaelto implement a remote-echoed, locally 110*47675Scael.Ql ^S/^Q 111*47675Scaelflow-controlled 11220740Smckusickremote login with proper back-flushing of output; it can be 11320740Smckusickused by other similar programs. 114*47675Scael.El 115*47675Scael.It Dv TIOCUCNTL 11628289SkarelsEnable/disable a mode that allows a small number of simple user 117*47675Scael.Xr ioctl 11828289Skarelscommands to be passed through the pseudo-terminal, 119*47675Scaelusing a protocol similar to that of 120*47675Scael.Dv TIOCPKT . 121*47675ScaelThe 122*47675Scael.Dv TIOCUCNTL 123*47675Scaeland 124*47675Scael.Dv TIOCPKT 125*47675Scaelmodes are mutually exclusive. 12628289SkarelsThis mode is enabled from the master side of a pseudo terminal 12728289Skarelsby specifying (by reference) 12828289Skarelsa nonzero parameter and disabled by specifying (by reference) 12928289Skarelsa zero parameter. 13028289SkarelsEach subsequent 131*47675Scael.Xr read 13228289Skarelsfrom the master side will return data written on the slave part of 13328289Skarelsthe pseudo terminal preceded by a zero byte, 13428289Skarelsor a single byte reflecting a user control operation on the slave side. 13528289SkarelsA user control command consists of a special 136*47675Scael.Xr ioctl 137*47675Scaeloperation with no data; the command is given as 138*47675Scael.Dv UIOCCMD Ns (n) , 139*47675Scaelwhere 140*47675Scael.Ar n 141*47675Scaelis a number in the range 1-255. 142*47675ScaelThe operation value 143*47675Scael.Ar n 144*47675Scaelwill be received as a single byte on the next 145*47675Scael.Xr read 14628289Skarelsfrom the master side. 147*47675ScaelThe 148*47675Scael.Xr ioctl 149*47675Scael.Dv UIOCCMD Ns (0) 150*47675Scaelis a no-op that may be used to probe for 15128289Skarelsthe existence of this facility. 152*47675ScaelAs with 153*47675Scael.Dv TIOCPKT 154*47675Scaelmode, command operations may be detected with a 155*47675Scael.Xr select 15628289Skarelsfor exceptional conditions. 157*47675Scael.It Dv TIOCREMOTE 15820740SmckusickA mode for the master half of a pseudo terminal, independent 159*47675Scaelof 160*47675Scael.Dv TIOCPKT . 161*47675ScaelThis mode causes input to the pseudo terminal 16220740Smckusickto be flow controlled and not input edited (regardless of the 16320740Smckusickterminal mode). Each write to the control terminal produces 16420740Smckusicka record boundary for the process reading the terminal. In 16520740Smckusicknormal usage, a write of data is like the data typed as a line 16620740Smckusickon the terminal; a write of 0 bytes is like typing an end-of-file 167*47675Scaelcharacter. 168*47675Scael.Dv TIOCREMOTE 169*47675Scaelcan be used when doing remote line 17020740Smckusickediting in a window manager, or whenever flow controlled input 17120740Smckusickis required. 172*47675Scael.El 173*47675Scael.Sh FILES 174*47675Scael.Bl -tag -width /dev/tty[p-r][0-9a-f]x -compact 175*47675Scael.It Pa /dev/pty[p-r][0-9a-f] 176*47675Scaelmaster pseudo terminals 177*47675Scael.It Pa /dev/tty[p-r][0-9a-f] 178*47675Scaelslave pseudo terminals 179*47675Scael.El 180*47675Scael.Sh DIAGNOSTICS 18120740SmckusickNone. 182*47675Scael.Sh HISTORY 183*47675ScaelThe 184*47675Scael.Nm 185*47675Scaeldriver appeared in 186*47675Scael.Bx 4.2 . 187