Pseudo terminal

Pseudo terminal

In Unix, a pseudo terminal is a pseudo-device pair that provides a text terminal interface without associated virtual console, computer terminal or serial port hardware. Instead, a process replaces the role of the underlying hardware for the pseudo terminal session.

BSD PTYs

The slave device file, which generally has a nomenclature of /dev/tty [p-za-e] [0-9a-f] , has the appearance and supported system calls of any text terminal. Thus it has the understanding of a login session and session leader process (which is typically the shell program).

The master device file, which generally has a nomenclature of /dev/pty [p-za-e] [0-9a-f] , is the endpoint for communication with the terminal emulator. It receives the control requests and information from the other party over this interface and responds accordingly.

With the typical [p-za-e] naming, there can be at most 256 tty pairs. Also, finding the first free pty master is not entirely race-free.

Unix98 PTYs

BSD PTYs have been made obsolete by Unix98 ptys, which allow race-free access and their number is not limited by naming nomenclature, only by implementation.

/dev/ptmx is the "pseudo-terminal master multiplexer" which, when opened, causes a slave node /dev/pts/"N" node to appear (with "N" being an integer). The file descriptor, obtained by opening ptmx plus the slave node, form the tty pair. [ [http://linux.die.net/man/4/pts pts(4): pseudo-terminal master/slave - Linux man page ] ]

Creating Pseudo Terminals

Pseudo terminals can be created using ordinary system calls to open an available master device file, in which a file descriptor to the master file is returned to the calling process. Library functions usually also exist that open the first available master device file and initialize privileges of the corresponding slave device (e.g. openpty(3) on BSD Unix systems).

For example, if the first master device file available is /dev/ptypa, most library functions will return a descriptor for the master (/dev/ptypa) along with a descriptor for the corresponding slave (/dev/ttypa), and establish the permissions of the slave device file in some predefined fashion.

It is generally not allowed to open a pseudo terminal master device that is currently open elsewhere.

Some systems, notably System V derived ones, include a multiplexer device (usually /dev/ptmx) that, when opened, will return a descriptor associated to the first available master device.

Applications

Important applications of pseudo terminals include "xterm" and similar terminal emulators in the X Window System and other window systems (such as the Terminal application in Mac OS X), in which the terminal emulator process is associated with the master device and the shell is associated with the slave. Any terminal operations performed by the shell in a terminal emulator session are received and handled by the terminal emulator process itself (such as terminal resizing or terminal resets). The terminal emulator process receives input from the keyboard and mouse using windowing events, and is thus able to transmit these characters to the shell, giving the shell the appearance of the terminal emulator being an underlying hardware object.

Other important applications include remote login handlers such as ssh and telnet servers, which serve as the master for a corresponding shell, bridged by a pseudo terminal.

Another key application is expect, which allows the automation of arbitrary terminal-bound subprocesses by using a pseudo-terminal to conceal the fact that the subprocess is being controlled by a program and not a user (many programs change their observed behavior otherwise, often because of varying default buffering semantics).

Origins

Pseudo terminals originated in 1983 with the 4.2 release of BSD. AT&T's System V included support for pseudo terminals as a driver in their STREAMS device model, along with the pseudo terminal multiplexer.

ee also

*tty

References


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Terminal restriction fragment length polymorphism — (TRFLP or sometimes T RFLP) is a molecular biology technique for profiling of microbial communities based on the position of a restriction site closest to a labeled end of an amplified gene. The method is based on digesting a mixture of PCR… …   Wikipedia

  • Terminal — may mean: In travel and transport *Pharmaceutical Buying House , is a private initiative global trading platform, located in Dhaka, Bangladesh *Airport terminal, a building at an airport *Bus terminal, a bus station *Container terminal, a… …   Wikipedia

  • Pseudo-transparency — is a term used for X Window System clients that simulate the appearance of translucency or transparency by manipulating the same pixmap that has been drawn on the root window, or by instructing the X Server that the Background Pixmap should be… …   Wikipedia

  • Terminal Velocity (video game) — Infobox VG title = Terminal Velocity developer = Terminal Reality publisher = 3D Realms distributor = FormGen designer = engine = version = released = May 1, 1995 genre = First person shooter modes = Single player, Multiplayer ratings = RSAC: V1 …   Wikipedia

  • Terminal (Film) — Filmdaten Deutscher Titel Terminal Originaltitel The Terminal Produktionsl …   Deutsch Wikipedia

  • Terminator (terminal emulator) — Infobox Software name = Terminator caption = Terminator on Mac OS X showing live search highlighting and UTF 8 capabilities, courtesy of Markus Kuhn s UTF 8 demo.txt and cat. developer = Phil Norman, Elliott Hughes, Martin Dorey latest release… …   Wikipedia

  • Virtual terminal — In open systems, a virtual terminal (VT) is an application service that: # Allows host terminals on a multi user network to interact with other hosts regardless of terminal type and characteristics, # Allows remote log on by local area network… …   Wikipedia

  • The Terminal — Filmdaten Deutscher Titel: Terminal Originaltitel: The Terminal Produktionsland: USA Erscheinungsjahr: 2004 Länge: 124 Minuten Originalsprache: Englisch …   Deutsch Wikipedia

  • Vitebsky Rail Terminal — Vitebsk Rail Terminal ( ru. Витебский вокзал), formerly known as the Tsarskoe Selo Station , was the first railway station to be built in Saint Petersburg and the whole of the Russian Empire. Early history The station, located at the crossing of… …   Wikipedia

  • PTY — • Pseudo TTY, benutzt bei Datentransfer • Pseudo Terminal • Panama City, Panama internationale Flughafen Kennung …   Acronyms

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”