pty
pseudo terminal driver
pseudo-device pty [count]
Provides support for a character device-pair known as a pseudo terminal,
a primary device and a replica device. The replica device provides a process with an interface
provided by another process manipulating it through the primary half of the pseudo terminal. Anything written on the primary device is
given to the replica device as input and anything written on the replica device is presented as input on the primary
device.
count is the number of pseudo terminal pairs
configured; the default is 32.
These ioctl(2) calls apply to pseudo terminals:
TIOCSTOP | Stops output to a terminal as with typing x-off.
| TIOCSTART | Restarts output (as typing x-on) stopped by TIOCSTOP or by typing x-off).
| TIOCPKT Enable/disable packet mode, enabled by specifying (by reference) a nonzero parameter and
disabled by specifying (by reference) a zero parameter. When applied to the primary side of a pseudo
terminal, each subsequent read(2) from the terminal will return data written on the replica part of the
pseudo terminal preceded by a zero byte (TIOCPKT_DATA), or a single byte
reflecting control status information, an OR of of the bits:
TIOCPKT_FLUSHREAD | whenever the read queue for the terminal is flushed.
| TIOCPKT_FLUSHWRITE | 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 restarted.
| 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 control status information to be read from the primary side
may be detected by a select(2) for exceptional conditions.
Used by rlogin and rlogind to implement a remote-echoed, locally ^S/^Q
( x-of/x-on) flow-
controlled remote login with proper back-flushing of output; it can be used by other similar programs.
TIOCUCNTL Enable/disable the mode that allows a small number of simple user ioctl(2) 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 primary side of a pseudo terminal by specifying (by
reference) a nonzero parameter and disabled by specifying (by reference) a zero parameter.
Each read from the primary side will return data written on the replica part of the pseudo
terminal preceded by a control byte (which may be 00) reflecting a user control operation on the replica
side. A user control command consists of a special ioctl operation with no data;
The command is given as UIOCCMD(n), where n is in the range 1-255.
The operation value n will be received as
a single byte on the next read(2) from the primary side.
ioctl(2) UIOCCMD(0) is a no-op that may be
used to probe for the existence of this facility.
As with TIOCPKT mode, command operations may be detected with select(2) for exceptional conditions.
| | | | | |
Files
/dev/pty[p-sP-S][a-z0-9] primary pseudo terminals
/dev/tty[p-sP-S][a-z0-9] replica pseudo terminals
Note:
/dev/tty is the controlling terminal for the current process.
To display tty's attached to which processes use ps -a.
ioctl
control device
#include <sys/ioctl.h>
int
ioctl(int fildes, unsigned long request, …);
Manipulates the operating characteristics of ttys.
fildes must be an open file descriptor.
A request has encoded in it whether it is an "in" parameter or "out" parameter, and the size of
the in bytes.
If an error occurrs, -1 is returned and errno is set to indicate the error.
ERRORS
Fails with:
[EBADF] fildes is a BAD File descriptor.
| [EINVAL] request or argp is INVALid.
| [ENOTTY] fildes is not associated with a tty.
OR
request does not apply.
| | | |
SEE
cdio(1), chio(1), mt(1), execve(2), fcntl(2), intro(4), tty(4)