[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4 Files Reference

pty Special File

Purpose

Provides the pseudo-terminal (pty) device driver.

Description

The pty device driver provides support for a pseudo-terminal. A pseudo-terminal includes a pair of control and slave character devices. The slave device provides processes with essentially the same interface as that provided by the tty device driver. However, instead of providing support for a hardware device, the slave device is manipulated by another process through the control half of the pseudo-terminal. That is, anything written on the control device is given to the slave device as input and anything written on the slave device is presented as input on the control device.

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 slave 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 slave 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 slave sides of an unused pseudo-terminal. The name of the corresponding slave side can be retrieved using the ttyname subroutine, which always returns the name of the slave side.

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 slave 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:
TIOCPKT_FLUSHREAD The read queue for the terminal is flushed.
TIOCPKT_FLUSHWRITE The write queue for the terminal is flushed.
TIOCPKT_STOP Output to the terminal is stopped with Ctrl-S.
TIOCPKT_START Output to the terminal is restarted.
TIOCPKT_DOSTOP The stop character defined by the current tty line discipline is Ctrl-S; the start character defined by the line discipline is Ctrl-Q.
TIOCPKT_NOSTOP The start and stop characters are not Ctrl-S and Ctrl-Q.

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 slave part of the pseudo-terminal, preceded either by a zero byte or by a single byte that reflects a user control operation on the slave 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.

Implementation Specifics

This file is part of Base Operating System (BOS) Runtime.

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:

Control devices /dev/pty[p-zA-Z][0-f]
Slave devices /dev/tty[p-zA-Z][0-f]

These special files are not symbolic links to the AIX special files. The BSD special files are completely separate from the AIX special files. The number of control and slave pair devices using the BSD naming convention is configurable.

In version 3 of the operating system, the pty subsystem used two multiplexed special files, /dev/ptc and /dev/pts. These special files no longer exist, but the procedure for opening a pty device is the same.

Related Information

The rlogin command, rlogind command.

The ioctl subroutine, ttyname subroutine.

The Special Files Overview.

tty Subsystem Overview in AIX General Programming Concepts: Writing and Debugging Programs.

Understanding TTY Drivers in AIX General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]