ArticleslgStudy

science

Pseudoterminal

Pseudoterminal is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Pseudoterminal rather than just read about it. In short: In some operating systems, including Unix-like systems, a pseudoterminal, pseudotty, or PTY is a pair of pseudo-device endpoints (files) which establish an asynchronous, bidirectional communication (IPC) channel (with two ports) between two or more processes. One pseudo-device in the pair, the master, provides means by which a terminal emulator or remote login server (e.g. a Telnet, rlogin, or Secure Shell server) p…

Pseudoterminal — main illustration
Pseudoterminal — illustration

Key takeaways

  • Pseudoterminal belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Pseudoterminal to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Pseudoterminal from memory before moving on to harder problems.

Reference excerpt

In some operating systems, including Unix-like systems, a pseudoterminal, pseudotty, or PTY is a pair of pseudo-device endpoints (files) which establish an asynchronous, bidirectional communication (IPC) channel (with two ports) between two or more processes. One pseudo-device in the pair, the master, provides means by which a terminal emulator or remote login server (e.g. a Telnet, rlogin, or Secure Shell server) process controls the slave. The other pseudo-device, the slave, emulates a hardware serial port device, and is used by terminal-oriented programs such as shells (e.g. bash) as a processes to read/write data back from/to master endpoint. PTYs are similar to bidirectional pipes. Devpts is a Linux kernel virtual file system containing pseudoterminal devices. Linux implementation is based on System V-style terminals (commonly referred as UNIX 98 pseudoterminals) and provides POSIX and the Single Unix Specification API in the form of a posix_openpt() function since 1998.

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. Some other DEC operating systems also had PTYs, including RSTS/E 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.3BSD-Reno, with a rather cumbersome openpty() interface defined for use. AT&T's System V included support for pseudoterminals as a driver in their STREAMS device model, along with the pseudoterminal multiplexer (/dev/ptmx). This later evolved to become the Unix98 style of PTYs. Pseudoterminals have been standardized by the Single UNIX Specification (maintained by the Austin Group) since 2004 (Issue 6). From Issue 8 (2024) the description adopts inclusive language by replacing the word master with manager and the word slave with subsidiary (defect 1466).

Books The Linux Programming Interface 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 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, GNOME Terminal, Konsole, and Terminal. Remote login servers such as Secure Shell and Telnet servers play the same role but communicate with a remote user instead of a local one. Screen and Tmux 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[p-za-e][0-9a-f], supports all system calls applicable to text terminal devices. Thus it supports login sessions. The master device file, which generally has a name of the form /dev/pty[p-za-e][0-9a-f], is the endpoint for communication with the terminal emulator. With the BSD [p-za-e] naming scheme, there can be at most 256 tty pairs. Also, finding the first free pty master can introduce a race condition unless a locking scheme is adopted. For that reason, some BSD operating systems, such as FreeBSD, OpenBSD, and DragonFly BSD, and the BSD-based macOS, have added support for 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

References

External links Containers, pseudo TTYs, and backward compatibility, LWN.net, June 1, 2016, by Neil Brown

Illustrations

Pseudoterminal: Pseudoterminals as they are used by the script Unix command that records user's input for replaying it later
Pseudoterminals as they are used by the script Unix command that records user's input for replaying it later

Worked examples

Example 1 — a first encounter with Pseudoterminal

Start with the simplest possible case. Write down what Pseudoterminal claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Pseudoterminal before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Pseudoterminal ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Pseudoterminal

In research
Pseudoterminal appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Pseudoterminal in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Pseudoterminal is common in secondary-school and first-year university syllabi. It links to neighbouring topics Technical communication tools, Terminal emulators, so understanding it makes those chapters shorter.
In everyday life
Look for Pseudoterminal outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Pseudoterminal” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Pseudoterminal in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Pseudoterminal means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Pseudoterminal out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Pseudoterminal in simple terms?

In some operating systems, including Unix-like systems, a pseudoterminal, pseudotty, or PTY is a pair of pseudo-device endpoints (files) which establish an asynchronous, bidirectional communication (IPC) channel (with two ports) between two or more processes. One pseudo-device in the pair, the mast…

Why does Pseudoterminal matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Pseudoterminal?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Pseudoterminal.

Tags

  • Technical communication tools
  • Terminal emulators

Keep exploring