pty Special File
Provides the pseudo-terminal (pty) device driver.
In AIX® Version 4, the pty subsystem uses naming conventions similar to those from UNIX System V. There is one node for the control driver, /dev/ptc, and a maximum number of N nodes for the worker drivers, /dev/pts/n. N is configurable at pty configuration and may be changed dynamically by pty reconfiguration, without closing the opened devices.
The control device is set up as a clone device whose major device number is the clone device's major number and whose minor device number is the control driver's major number. There is no node in the filesystem for control devices. A control device can be opened only once, but worker devices can be opened several times.
By opening the control device with the /dev/ptc special file, an application can quickly open the control and worker sides of an unused pseudo-terminal. The name of the corresponding worker side can be retrieved using the ttyname subroutine, which always returns the name of the worker side.
With Berkeley pty subsystems, commands have to search for an unused pseudo-terminal by opening each control side sequentially. The control side could not be opened if it was already in use. Thus, the opens would fail, setting the errno variable to EIO, until an unused pseudo-terminal was found. It is possible to configure the pty subsystem in order to use special files with the BSD pty naming convention:
These special files are not symbolic links to the operating system special files. They are completely separate. The number of control and worker pair devices using the BSD naming convention is configurable.
The following ioctl commands apply to pseudo-terminals:
|TIOCSTOP||Stops output to a terminal. This is the same as using the Ctrl-S key sequence. No parameters are allowed for this command.|
|TIOCSTART||Restarts output that was stopped by a TIOCSTOP command or by the Ctrl-S key sequence. This is the same as typing the Ctrl-Q key sequence. No parameters are allowed for this command.|
|TIOCPKT|| Enables and disables the packet mode. Packet mode is enabled by specifying (by reference) a
nonzero parameter. It is disabled by specifying (by reference) a zero parameter. When applied to the
control side of a pseudo-terminal, each subsequent read from the terminal returns data written on
the worker part of the pseudo terminal. The data is preceded either by a zero byte (symbolically
defined as TIOCPKT_DATA) or by a single byte that reflects control-status information. In the
latter case, the byte is an inclusive OR of zero or more of the following bits:
While this mode is in use, the presence of control-status information to be read from the control side can be detected by a select for exceptional conditions.
This mode is used by the rlogin and rlogind commands to log in to a remote host and implement remote echoing and local Ctrl-S and Ctrl-Q flow control with proper back-flushing of output.
|TIOCUCNTL|| Enables and disables 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 the TIOCPKT
mode. The TIOCUCNTL and TIOCPKT modes are mutually exclusive.
This mode is enabled from the control side of a pseudo-terminal by specifying (by reference) a nonzero parameter. It is disabled by specifying (by reference) a zero parameter. Each subsequent read from the control side will return data written on the worker part of the pseudo-terminal, preceded either by a zero byte or by a single byte that reflects a user control operation on the worker side.
A user-control command consists of a special ioctl operation with no data. That command is issued as UIOCCMD(Value), where the Value parameter specifies a number in the range 1 through 255. The operation value is received as a single byte on the next read from the control side.
A value of 0 can be used with the UIOCCMD ioctl operation to probe for the existence of this facility. The zero is not made available for reading by the control side. Command operations can be detected with a select for exceptional conditions.
|TIOCREMOTE||A mode for the control half of a pseudo-terminal, independent of TIOCPKT. This mode implements flow control, rather than input editing, for input to the pseudo-terminal, regardless of the terminal mode. Each write to the control terminal produces 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 terminal, while a write of zero bytes is like typing an end-of-file character. This mode is used for remote line editing in a window-manager and flow-controlled input.|