Pseudo terminal
   HOME

TheInfoList



OR:

In some
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s, including
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
and
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, w ...
, a pseudoterminal, pseudotty, or PTY is a pair of
pseudo-device In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow a ...
endpoints (files) which establish asynchronous, bidirectional communication ( IPC) channel (with two ports) between two or more processes. The ''master'' provides means by which a
terminal emulator A terminal emulator, or terminal application, is a computer program that emulates a video terminal within some other display architecture. Though typically synonymous with a shell or text terminal, the term ''terminal'' covers all remote term ...
process A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic. Things called a process include: Business and management *Business process, activities that produce a specific se ...
controls the slave. The ''slave'', emulates a hardware
text terminal A computer terminal is an electronic or electromechanical hardware device that can be used for entering data into, and transcribing data from, a computer or a computing system. The teletype was an example of an early-day hard-copy terminal and ...
device. PTY are similar to bidirectional pipes. The ''master'' files are typically used by networking applications (e.g. rlogin) and ''slave'' files are used by terminal-oriented programs such as shells (e.g. bash) as a processes to read/write data back from/to ''master'' endpoint. Common application of PTYs is in providing network login services. Devpts is a Linux Kernel virtual file system used to emulate PTYs connection. Linux implementation is based on
System V Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
-style terminals (commonly referred as UNIX 98 pseudoterminals) and provides
POSIX The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inter ...
and the Single Unix Specification API in the form of a function since 1998. Unix command is typically used to get PTY file path connected to the current
standard input In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin ...
.


History

Pseudoterminals were present in the DEC PDP-6 Timesharing Monitor at least as early as 1967, and were used to implement batch processing. They are described in the documentation for the succeeding TOPS-10 on the
PDP-10 Digital Equipment Corporation (DEC)'s PDP-10, later marketed as the DECsystem-10, is a mainframe computer family manufactured beginning in 1966 and discontinued in 1983. 1970s models and beyond were marketed under the DECsystem-10 name, espec ...
. Other DEC operating systems also had PTYs, including
RSTS/E RSTS () is a multi-user time-sharing operating system developed by Digital Equipment Corporation (DEC, now part of Hewlett-Packard) for the PDP-11 series of 16-bit minicomputers. The first version of RSTS (RSTS-11, Version 1) was implemented in 1 ...
for the PDP-11, as did the third-party TENEX operating system for the PDP-10. Implementations of Unix pseudo terminals date back to the modifications that RAND and BBN made to a 6th Edition in the late 1970s to support remote access over a network. Modern Unix pseudoterminals originated in 1983 during the development of Eighth Edition Unix and were based on a similar feature in TENEX. They were part of the 4.2 release of BSD, with a rather cumbersome interface defined for use. AT&T's
System V Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
included support for pseudoterminals as a driver in their STREAMS device model, along with the pseudoterminal multiplexer (). This later evolved to become the Unix98 style of PTYs.


Books

''
The Linux Programming Interface ''The Linux Programming Interface: A Linux and UNIX System Programming Handbook'' is a book written by Michael Kerrisk, which documents the APIs of the Linux kernel and of the GNU C Library (glibc). Book It covers a wide array of topics deali ...
'' from 2010 contains an entire chapter (chapter 64 "Pseudoterminals" p1375–1399.) explaining pseudoterminals. Then there is another one, Chapter 62 "Terminals", dedicated to terminals. The
Windows Console Windows Console is the infrastructure for console applications in Microsoft Windows. An instance of a Windows Console has a screen buffer and an input buffer. It allows console apps to run inside a window or in hardware text mode (so as to oc ...
was extended to have a PTY interface called ConPTY in 2018.


Applications

The role of the terminal emulator process is: * to interact with the user, * to feed text input to the master pseudo-device for use by the shell (such as bash), which is connected to the slave pseudo-device, * to read text output from the master pseudo-device and show it to the user. The terminal emulator process must also handle terminal control commands, e.g., for resizing the screen. Widely used terminal emulator programs include ''
xterm In computing, xterm is the standard terminal emulator for the X Window System. It allows users to run programs which require a command-line interface. If no particular program is specified, xterm runs the user's shell. An X display can sho ...
'',
GNOME Terminal GNOME Terminal is a terminal emulator for the GNOME desktop environment written by Havoc Pennington and others. Terminal emulators allow users to access a UNIX shell while remaining on their graphical desktop. Features GNOME Terminal (gnome-term ...
, Konsole, and '' Terminal (macOS)''. Remote login handlers such as ssh and
telnet Telnet is an application protocol used on the Internet or local area network to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection. User data is interspersed in-band with Telnet contr ...
servers play the same role but communicate with a remote user instead of a local one. Also consider programs such as
expect Expect is an extension to the Tcl scripting language written by Don Libes. The program automates interactions with programs that expose a text terminal interface. Expect, originally written in 1990 for the Unix platform, has since become avail ...
.
Screen Screen or Screens may refer to: Arts * Screen printing (also called ''silkscreening''), a method of printing * Big screen, a nickname associated with the motion picture industry * Split screen (filmmaking), a film composition paradigm in which mul ...
and
Tmux tmux is an open-source terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time. ...
are used to add a session context to a pseudoterminal, making for a much more robust and versatile solution. For example, each provides terminal persistence, allowing a user to disconnect from one computer and then connect later from another computer.


Variants

In the BSD PTY system, the slave device file, which generally has a name of the form /dev/tty -za-e0-9a-f], supports all
system call In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
s applicable to text terminal devices. Thus it supports
login session In computing, a login session is the period of activity between a user logging in and logging out of a (multi-user) system. On Unix and Unix-like operating systems, a login session takes one of two main forms: * When a textual user interface i ...
s. The master device file, which generally has a name of the form /dev/pty -za-e0-9a-f], is the endpoint for communication with the terminal emulator. With this naming scheme, there can be at most 256 tty pairs. Also, finding the first free pty master can be Race condition, racy unless a locking scheme is adopted. For that reason, recent BSD operating systems, such as FreeBSD, implement Unix98 PTYs. BSD PTYs have been rendered obsolete by Unix98 ptys whose naming system does not limit the number of pseudo-terminals and access to which occurs without danger of race conditions. /dev/ptmx is the "pseudo-terminal master multiplexer". Opening it returns a file descriptor of a master node and causes an associated slave node /dev/pts/''N'' to be created.


See also

*
List of Unix commands This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems. List See also * List of G ...


References

{{Reflist


External links


Containers, pseudo TTYs, and backward compatibility
LWN.net LWN.net is a computing webzine with an emphasis on free software and software for Linux and other Unix-like operating systems. It consists of a weekly issue, separate stories which are published most days, and threaded discussion attached to ...
, June 1, 2016, by Neil Brown Terminal emulators Technical communication tools