PTY(7D) | Devices | PTY(7D) |
pty
— legacy
pseudo-terminal driver
/dev/pty[p-r]*
/dev/tty[p-r]*
This driver provides support for legacy static pseudo-terminal devices. Modern software does not use this driver, preferring instead the STREAMS-based ptm(7D) and pts(7D) pseudo-terminal drivers, consumed through the portable posix_openpt(3C) interface.
The pty
driver
provides support for a pair of devices collectively known as a
pseudo-terminal.
The two devices comprising a pseudo-terminal are known as a
manager
and a
subsidiary.
The subsidiary device distinguishes between the B0 baud
rate and other baud rates specified in
the
c_cflag field of the termios
structure, and the CLOCAL
flag in that member. It
does not support any of the other termio(7I) device
control functions specified by flags in the c_cflag
field of the termios structure and by the
IGNBRK
, IGNPAR
,
PARMRK
, or INPCK
flags in
the c_iflag field of the termios
structure, as these functions apply only to asynchronous serial ports. All
other termio(7I) functions must be performed by STREAMS
modules pushed atop the driver; when a subsidiary device is opened, the
ldterm(7M) and ttcompat(7M) STREAMS
modules are automatically pushed on top of the stream, providing the
standard termio(7I) interface.
Instead of having a hardware interface and associated hardware that supports the terminal functions, the functions are implemented by another process manipulating the manager device of the pseudo-terminal.
The manager and the subsidiary devices of the pseudo-terminal are tightly connected. Any data written on the manager device is given to the subsidiary device as input, as though it had been received from a hardware interface. Any data written on the subsidiary terminal can be read from the manager device (rather than being transmitted from a UAR).
The driver is statically configured to provide 48 pseudo-terminal pairs. Software that requires dynamic pseudo-terminal devices, or a greater number of devices, must be converted to use ptm(7D).
The standard set of termio(7I) ioctls are
supported by the subsidiary device. None of the bits in the
c_cflag field have any effect on the pseudo-terminal,
except that if the baud rate is set to B0
, it will
appear to the process on the manager device as if the last process on the
subsidiary device had closed the line; thus, setting the baud rate to
B0
has the effect of “hanging up” the
pseudo-terminal, just as it has the effect of “hanging up” a
real terminal.
There is no notion of “parity” on a pseudo-terminal, so none of the flags in the c_iflag field that control the processing of parity errors have any effect. Similarly, there is no notion of a break, so none of the flags that control the processing of breaks, and none of the ioctls that generate breaks, have any effect.
Input flow control is automatically performed; a process that
attempts to write to the manager device will be blocked if too much
unconsumed data is buffered on the subsidiary device. The input flow control
provided by the IXOFF
flag in the
c_iflag field is not supported.
The delays specified in the c_oflag field are not supported.
As there are no modems involved in a pseudo-terminal, the ioctls that return or alter the state of modem control lines are silently ignored.
A few special ioctls are provided on the manager devices of pseudo-terminals to provide the functionality needed by applications programs to emulate real hardware interfaces:
TIOCSTOP
TIOCSTART
TIOCPKT
TIOCPKT_DATA
), or a
single byte reflecting control status information. In the latter case, the
byte is an inclusive-or of zero or more of the bits:
TIOCPKT_FLUSHREAD
TIOCPKT_FLUSHWRITE
TIOCPKT_STOP
TIOCPKT_START
TIOCPKT_DOSTOP
IXON
flag in the c_iflag
field is set, the VSTOP
member of the
c_cc array is ^S and the
VSTART
member of the
c_cc array is
^Q.TIOCPKT_NOSTOP
TIOCREMOTE
Each write to the manager device produces a record boundary for the process reading the subsidiary device. In normal usage, a write of data is like the data typed as a line on the terminal; a write of 0 bytes is like typing an EOF character. Note: this means that a process writing to a pseudo-terminal manager in remote mode must keep track of line boundaries, and write only one line at a time to the manager.
If, for example, it were to buffer up several newline characters and write them to the manager with one write(2), it would appear to a process reading from the subsidiary as if a single line containing several newline characters had been typed (as if, for example, a user had typed the literal next (LNEXT) character before typing all but the last of those newline characters). Remote mode can be used when doing remote line editing in a window manager, or whenever flow controlled input is required.
rlogin(1), rlogind(1M), posix_openpty(3C), ptm(7D), termio(7I), ldterm(7M), ttcompat(7M)
This is a legacy device and should not be used by new software.
It is apparently not possible to send an
EOT by writing zero
bytes in TIOCREMOTE
mode.
February 5, 2022 | illumos |