xref: /csrg-svn/share/man/man4/pty.4 (revision 64994)
161599Sbostic.\" Copyright (c) 1983, 1991, 1993
261599Sbostic.\"	The Regents of the University of California.  All rights reserved.
320740Smckusick.\"
447675Scael.\" %sccs.include.redist.man%
520740Smckusick.\"
6*64994Smckusick.\"     @(#)pty.4	8.2 (Berkeley) 11/30/93
747675Scael.\"
847675Scael.Dd
947675Scael.Dt PTY 4
1047675Scael.Os BSD 4.2
1147675Scael.Sh NAME
1247675Scael.Nm pty
1347675Scael.Nd pseudo terminal driver
1447675Scael.Sh SYNOPSIS
1547675Scael.Nm pseudo-device pty
1647675Scael.Op Ar count
1747675Scael.Sh DESCRIPTION
1820740SmckusickThe
1947675Scael.Xr pty
2020740Smckusickdriver provides support for a device-pair termed a
2147675Scael.Em pseudo terminal .
2220740SmckusickA pseudo terminal is a pair of character devices, a
2347675Scael.Em master
2420740Smckusickdevice and a
2547675Scael.Em slave
26*64994Smckusickdevice.  The slave device provides to a process
2720740Smckusickan interface identical
2820740Smckusickto that described in
2947675Scael.Xr tty 4 .
3020740SmckusickHowever, whereas all other devices which provide the
3120740Smckusickinterface described in
3247675Scael.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.
4047675Scael.Pp
4147675ScaelIn configuring, if an optional
4247675Scael.Ar count
4347675Scaelis given in
4428289Skarelsthe specification, that number of pseudo terminal pairs are configured;
4528289Skarelsthe default count is 32.
4647675Scael.Pp
4720740SmckusickThe following
4847675Scael.Xr ioctl 2
4920740Smckusickcalls apply only to pseudo terminals:
5047675Scael.Bl -tag -width TIOCREMOTE
5147675Scael.It Dv TIOCSTOP
5247675ScaelStops output to a terminal (e.g. like typing
5347675Scael.Ql ^S ) .
5447675ScaelTakes
5520740Smckusickno parameter.
5647675Scael.It Dv TIOCSTART
5747675ScaelRestarts output (stopped by
5847675Scael.Dv TIOCSTOP
5947675Scaelor by typing
6047675Scael.Ql ^S ) .
6120740SmckusickTakes no parameter.
6247675Scael.It Dv TIOCPKT
6320740SmckusickEnable/disable
6447675Scael.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
6947675Scael.Xr read
7020740Smckusickfrom the terminal will return data written on the slave part of
7120740Smckusickthe pseudo terminal preceded by a zero byte (symbolically
7247675Scaeldefined as
7347675Scael.Dv TIOCPKT_DATA ) ,
7447675Scaelor a single byte reflecting control
7520740Smckusickstatus information.  In the latter case, the byte is an inclusive-or
7620740Smckusickof zero or more of the bits:
7747675Scael.Bl -tag -width TIOCPKT_FLUSHWRITE
7847675Scael.It Dv TIOCPKT_FLUSHREAD
7920740Smckusickwhenever the read queue for the terminal is flushed.
8047675Scael.It Dv TIOCPKT_FLUSHWRITE
8120740Smckusickwhenever the write queue for the terminal is flushed.
8247675Scael.It Dv TIOCPKT_STOP
8347675Scaelwhenever output to the terminal is stopped a la
8447675Scael.Ql ^S .
8547675Scael.It Dv TIOCPKT_START
8620740Smckusickwhenever output to the terminal is restarted.
8747675Scael.It Dv TIOCPKT_DOSTOP
8820740Smckusickwhenever
8947675Scael.Em t_stopc
9047675Scaelis
9147675Scael.Ql ^S
9220740Smckusickand
9347675Scael.Em t_startc
9447675Scaelis
9547675Scael.Ql ^Q .
9647675Scael.It Dv TIOCPKT_NOSTOP
9747675Scaelwhenever the start and stop characters are not
9847675Scael.Ql ^S/^Q .
9947675Scael.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
10247675Scael.Xr select 2
10328289Skarelsfor exceptional conditions.
10447675Scael.Pp
10520740SmckusickThis mode is used by
10647675Scael.Xr rlogin 1
10720740Smckusickand
10847675Scael.Xr rlogind 8
10947675Scaelto implement a remote-echoed, locally
11047675Scael.Ql ^S/^Q
11147675Scaelflow-controlled
11220740Smckusickremote login with proper back-flushing of output; it can be
11320740Smckusickused by other similar programs.
11447675Scael.El
11547675Scael.It Dv TIOCUCNTL
11628289SkarelsEnable/disable a mode that allows a small number of simple user
11747675Scael.Xr ioctl
11828289Skarelscommands to be passed through the pseudo-terminal,
11947675Scaelusing a protocol similar to that of
12047675Scael.Dv TIOCPKT .
12147675ScaelThe
12247675Scael.Dv TIOCUCNTL
12347675Scaeland
12447675Scael.Dv TIOCPKT
12547675Scaelmodes 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
13147675Scael.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
13647675Scael.Xr ioctl
13747675Scaeloperation with no data; the command is given as
13847675Scael.Dv UIOCCMD Ns (n) ,
13947675Scaelwhere
14047675Scael.Ar n
14147675Scaelis a number in the range 1-255.
14247675ScaelThe operation value
14347675Scael.Ar n
14447675Scaelwill be received as a single byte on the next
14547675Scael.Xr read
14628289Skarelsfrom the master side.
14747675ScaelThe
14847675Scael.Xr ioctl
14947675Scael.Dv UIOCCMD Ns (0)
15047675Scaelis a no-op that may be used to probe for
15128289Skarelsthe existence of this facility.
15247675ScaelAs with
15347675Scael.Dv TIOCPKT
15447675Scaelmode, command operations may be detected with a
15547675Scael.Xr select
15628289Skarelsfor exceptional conditions.
15747675Scael.It Dv TIOCREMOTE
15820740SmckusickA mode for the master half of a pseudo terminal, independent
15947675Scaelof
16047675Scael.Dv TIOCPKT .
16147675ScaelThis 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
16747675Scaelcharacter.
16847675Scael.Dv TIOCREMOTE
16947675Scaelcan be used when doing remote line
17020740Smckusickediting in a window manager, or whenever flow controlled input
17120740Smckusickis required.
17247675Scael.El
17347675Scael.Sh FILES
17447675Scael.Bl -tag -width /dev/tty[p-r][0-9a-f]x -compact
17547675Scael.It Pa /dev/pty[p-r][0-9a-f]
17647675Scaelmaster pseudo terminals
17747675Scael.It Pa /dev/tty[p-r][0-9a-f]
17847675Scaelslave pseudo terminals
17947675Scael.El
18047675Scael.Sh DIAGNOSTICS
18120740SmckusickNone.
18247675Scael.Sh HISTORY
18347675ScaelThe
18447675Scael.Nm
18547675Scaeldriver appeared in
18647675Scael.Bx 4.2 .
187