PTY(7-SysV) RISC/os Reference Manual PTY(7-SysV)
NAME
pty - pseudo terminal driver
SYNOPSIS
INCLUDE: pts[(count)]
INCLUDE: ptc[(count)]
DESCRIPTION
The pty driver provides support for a device-pair termed a
pseudo terminal. A pseudo terminal is a pair of character
devices, a master device and a slave device. The slave dev-
ice provides processes an interface identical to that
described in tty(7). However, whereas all other devices
which provide the interface described in tty(7) have a
hardware device of some sort behind them, the slave device
has, instead, another process manipulating it through the
master half of the pseudo terminal. That is, anything writ-
ten on the master device is given to the slave device as
input and anything written on the slave device is presented
as input on the master device.
In configuring, if an optional ``(count)'' is given in the
specification, that number times 256 pseudo terminal pairs
are configured; the default count is 1, for a total of 256
pairs.
The following ioctl calls apply only to pseudo terminals:
TIOCSTOP Stops output to a terminal (e.g. like typing
^S). Takes no parameter.
TIOCSTART Restarts output (stopped by TIOCSTOP or by typ-
ing ^S). Takes no parameter.
TIOCPKT Enable/disable packet mode. Packet mode is
enabled by specifying (by reference) a nonzero
parameter and disabled by specifying (by refer-
ence) a zero parameter. When applied to the
master side of a pseudo terminal, each subse-
quent read from the terminal will return data
written on the slave part of the pseudo terminal
preceded by a zero byte (symbolically defined as
TIOCPKT_DATA), or a single byte reflecting con-
trol status information. In the latter case,
the byte is an inclusive-or of zero or more of
the bits:
TIOCPKT_FLUSHREAD
whenever the read queue for the terminal is
flushed.
TIOCPKT_FLUSHWRITE
Printed 1/28/91 Page 1
PTY(7-SysV) RISC/os Reference Manual PTY(7-SysV)
whenever the write queue for the terminal
is flushed.
TIOCPKT_STOP
whenever output to the terminal is stopped
a la ^S.
TIOCPKT_START
whenever output to the terminal is res-
tarted.
TIOCPKT_DOSTOP
whenever t_stopc is ^S and t_startc is ^Q.
TIOCPKT_NOSTOP
whenever the start and stop characters are
not ^S/^Q.
While this mode is in use, the presence of con-
trol status information to be read from the mas-
ter side may be detected by a select for excep-
tional conditions.
This mode is used by rlogin(1) and rlogind(1M)
to implement a remote-echoed, locally ^S/^Q
flow-controlled remote login with proper back-
flushing of output; it can be used by other
similar programs.
TIOCUCNTL Enable/disable a mode that allows a small number
of simple user ioctl commands to be passed
through the pseudo-terminal, using a protocol
similar to that of TIOCPKT. The TIOCUCNTL and
TIOCPKT modes are mutually exclusive. This mode
is enabled from the master side of a pseudo ter-
minal by specifying (by reference) a nonzero
parameter and disabled by specifying (by refer-
ence) a zero parameter. Each subsequent read
from the master side will return data written on
the slave part of the pseudo terminal preceded
by a zero byte, or a single byte reflecting a
user control operation on the slave side. A
user control command consists of a special ioctl
operation with no data; the command is given as
UIOCCMD(n), where n is a number in the range
1-255. The operation value n will be received
as a single byte on the next read from the mas-
ter side. The ioctl UIOCCMD(0) is a no-op that
may be used to probe for the existence of this
facility. As with TIOCPKT mode, command opera-
tions may be detected with a select for
Page 2 Printed 1/28/91
PTY(7-SysV) RISC/os Reference Manual PTY(7-SysV)
exceptional conditions.
TIOCREMOTE A mode for the master half of a pseudo terminal,
independent of TIOCPKT. This mode causes input
to the pseudo terminal to be flow controlled and
not input edited (regardless of the terminal
mode). Each write to the control terminal pro-
duces a record boundary for the process reading
the terminal. In normal usage, a write of data
is like the data typed as a line on the termi-
nal; a write of 0 bytes is like typing an end-
of-file character. TIOCREMOTE can be used when
doing remote line editing in a window manager,
or whenever flow controlled input is required.
PTCSETCON A mode for the slave side of a psuedo terminal,
for use by the super-user only. This mode
causes the kernel output to the console to be
linked to the output of this slave psuedo termi-
nal. The master psuedo teminal may do what ever
is appropriate for kernel output. On last close
of this slave psuedo terminal, a PTCCLRCON is
performed. Note: this is used by xterm when the
-C option is used. Using this option requires
that the user include <sys/termio.h> in -systype
sysv, <sys/termios.h> in -systype posix, or
<sysv/sys/termio.h> in -systype bsd43, and
<sys/pty_ioctl.h> in -systype sysv or
<sysv/sys/pty_ioctl.h> otherwise. Only the cmd
field is used for this ioctl.
PTCCLRCON A mode for the slave side of a psuedo terminal,
for use by the super-user only. This mode
causes the kernel output to the console to be
unlinked from the output of this slave psuedo
terminal. Using this option requires that the
user include the header files mentioned for
PTCSETCON. This function is effectively executed
on the last close of the master psuedo terminal
that is reading the console output. Only the
cmd field is used for this ioctl.
A pseudo terminal may be opened either by attempting to open
each of the 4.3 BSD master pseudo terminal names, until an
open succeeds, or by opening one of the pseudo terminal
clone devices (/dev/ptc and /dev/ptcm). If the first
approach is used, the slave pseudo terminal has the same
name as the master pseudo terminal, except that "pty" is
replaced by "tty".
If /dev/ptc is used, the name of the slave pseudo terminal
is computed by calling fstat (see stat(2)) on the master
Printed 1/28/91 Page 3
PTY(7-SysV) RISC/os Reference Manual PTY(7-SysV)
pseudo terminal, and opening /dev/ttyq<minor> where
``<minor>'' is the decimal string equivalent to the minor
device number of the st_rdev attribute of the master termi-
nal. Thus, if the st_rdev value is 0xE12 (major 14, minor
18), the slave pseudo terminal name would be /dev/ttyq18.
If /dev/ptcm is used, the name of the slave pseudo terminal
is computed similarly, except that the ordinal of the master
major device number, multiplied by 256, is added to the
minor device number. The ordinal of the master major device
number is determined by performing a stat(2) on each of the
/dev/ptcm<ordinal> device names, where ``<ordinal>'' is a
single decimal digit, until one is found for which the major
device number of the st_rdev field matches the major device
number of the st_rdev attribute of the master pseudo termi-
nal. For example, if the st_rdev attribute of the master
pseudo terminal is 0x2D12 (major 45, minor 18), the program
will find that /dev/ptcm3 has an st_rdev attribute of 0x2D00
(major 45, minor 0), which matches, so that the major ordi-
nal is 3. Thus the slave pseudo terminal will be
/dev/ttyq786.
FILES
/dev/pty[p-z][0-9a-f] 4.3 BSD master pseudo terminals
/dev/tty[p-z][0-9a-f] 4.3 BSD slave pseudo terminals
/dev/ptc master pseudo terminal clone device
(first 256 pty's)
/dev/ptcm master pseudo terminal clone device
(all pty's)
/dev/ptmc[0-9] alternate master pseudo terminal
devices
/dev/ttyq[0-9]* slave pseudo terminals for cloned
masters
DIAGNOSTICS
None.
CAVEATS
TIOCUCNTL is currently not fully implemented.
Page 4 Printed 1/28/91