xref: /csrg-svn/share/man/man4/pty.4 (revision 68066)
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*68066Smckusick.\"     @(#)pty.4	8.3 (Berkeley) 12/08/94
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
2664994Smckusickdevice.  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.
62*68066Smckusick.Dv TIOCSIG
63*68066SmckusickSends the specified signal to the process group members of the
64*68066Smckusickpseudo terminal that have it as their controlling terminal.
6547675Scael.It Dv TIOCPKT
6620740SmckusickEnable/disable
6747675Scael.Em packet
6820740Smckusickmode.  Packet mode is enabled by specifying (by reference)
6920740Smckusicka nonzero parameter and disabled by specifying (by reference)
7020740Smckusicka zero parameter.  When applied to the master side of a pseudo
7120740Smckusickterminal, each subsequent
7247675Scael.Xr read
7320740Smckusickfrom the terminal will return data written on the slave part of
7420740Smckusickthe pseudo terminal preceded by a zero byte (symbolically
7547675Scaeldefined as
7647675Scael.Dv TIOCPKT_DATA ) ,
7747675Scaelor a single byte reflecting control
7820740Smckusickstatus information.  In the latter case, the byte is an inclusive-or
7920740Smckusickof zero or more of the bits:
8047675Scael.Bl -tag -width TIOCPKT_FLUSHWRITE
8147675Scael.It Dv TIOCPKT_FLUSHREAD
8220740Smckusickwhenever the read queue for the terminal is flushed.
8347675Scael.It Dv TIOCPKT_FLUSHWRITE
8420740Smckusickwhenever the write queue for the terminal is flushed.
8547675Scael.It Dv TIOCPKT_STOP
8647675Scaelwhenever output to the terminal is stopped a la
8747675Scael.Ql ^S .
8847675Scael.It Dv TIOCPKT_START
8920740Smckusickwhenever output to the terminal is restarted.
9047675Scael.It Dv TIOCPKT_DOSTOP
9120740Smckusickwhenever
9247675Scael.Em t_stopc
9347675Scaelis
9447675Scael.Ql ^S
9520740Smckusickand
9647675Scael.Em t_startc
9747675Scaelis
9847675Scael.Ql ^Q .
9947675Scael.It Dv TIOCPKT_NOSTOP
10047675Scaelwhenever the start and stop characters are not
10147675Scael.Ql ^S/^Q .
10247675Scael.Pp
10328289SkarelsWhile this mode is in use, the presence of control status information
10428289Skarelsto be read from the master side may be detected by a
10547675Scael.Xr select 2
10628289Skarelsfor exceptional conditions.
10747675Scael.Pp
10820740SmckusickThis mode is used by
10947675Scael.Xr rlogin 1
11020740Smckusickand
11147675Scael.Xr rlogind 8
11247675Scaelto implement a remote-echoed, locally
11347675Scael.Ql ^S/^Q
11447675Scaelflow-controlled
11520740Smckusickremote login with proper back-flushing of output; it can be
11620740Smckusickused by other similar programs.
11747675Scael.El
11847675Scael.It Dv TIOCUCNTL
11928289SkarelsEnable/disable a mode that allows a small number of simple user
12047675Scael.Xr ioctl
12128289Skarelscommands to be passed through the pseudo-terminal,
12247675Scaelusing a protocol similar to that of
12347675Scael.Dv TIOCPKT .
12447675ScaelThe
12547675Scael.Dv TIOCUCNTL
12647675Scaeland
12747675Scael.Dv TIOCPKT
12847675Scaelmodes are mutually exclusive.
12928289SkarelsThis mode is enabled from the master side of a pseudo terminal
13028289Skarelsby specifying (by reference)
13128289Skarelsa nonzero parameter and disabled by specifying (by reference)
13228289Skarelsa zero parameter.
13328289SkarelsEach subsequent
13447675Scael.Xr read
13528289Skarelsfrom the master side will return data written on the slave part of
13628289Skarelsthe pseudo terminal preceded by a zero byte,
13728289Skarelsor a single byte reflecting a user control operation on the slave side.
13828289SkarelsA user control command consists of a special
13947675Scael.Xr ioctl
14047675Scaeloperation with no data; the command is given as
14147675Scael.Dv UIOCCMD Ns (n) ,
14247675Scaelwhere
14347675Scael.Ar n
14447675Scaelis a number in the range 1-255.
14547675ScaelThe operation value
14647675Scael.Ar n
14747675Scaelwill be received as a single byte on the next
14847675Scael.Xr read
14928289Skarelsfrom the master side.
15047675ScaelThe
15147675Scael.Xr ioctl
15247675Scael.Dv UIOCCMD Ns (0)
15347675Scaelis a no-op that may be used to probe for
15428289Skarelsthe existence of this facility.
15547675ScaelAs with
15647675Scael.Dv TIOCPKT
15747675Scaelmode, command operations may be detected with a
15847675Scael.Xr select
15928289Skarelsfor exceptional conditions.
16047675Scael.It Dv TIOCREMOTE
16120740SmckusickA mode for the master half of a pseudo terminal, independent
16247675Scaelof
16347675Scael.Dv TIOCPKT .
16447675ScaelThis mode causes input to the pseudo terminal
16520740Smckusickto be flow controlled and not input edited (regardless of the
16620740Smckusickterminal mode).  Each write to the control terminal produces
16720740Smckusicka record boundary for the process reading the terminal.  In
16820740Smckusicknormal usage, a write of data is like the data typed as a line
16920740Smckusickon the terminal; a write of 0 bytes is like typing an end-of-file
17047675Scaelcharacter.
17147675Scael.Dv TIOCREMOTE
17247675Scaelcan be used when doing remote line
17320740Smckusickediting in a window manager, or whenever flow controlled input
17420740Smckusickis required.
17547675Scael.El
17647675Scael.Sh FILES
17747675Scael.Bl -tag -width /dev/tty[p-r][0-9a-f]x -compact
17847675Scael.It Pa /dev/pty[p-r][0-9a-f]
17947675Scaelmaster pseudo terminals
18047675Scael.It Pa /dev/tty[p-r][0-9a-f]
18147675Scaelslave pseudo terminals
18247675Scael.El
18347675Scael.Sh DIAGNOSTICS
18420740SmckusickNone.
18547675Scael.Sh HISTORY
18647675ScaelThe
18747675Scael.Nm
18847675Scaeldriver appeared in
18947675Scael.Bx 4.2 .
190