Linux TTY: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 21: Line 21:
TTY session management allows one user to interact with multiple processes running simultaneously in user space, one at a time. This includes the capability to suspend, kill or send programs to background, bring programs into foreground, and direct the user input to the [[Linux_General_Concepts#Foreground_Process|foreground process]] only. The TTY subsystem implements these features in the [[#TTY_Driver|TTY driver]].
TTY session management allows one user to interact with multiple processes running simultaneously in user space, one at a time. This includes the capability to suspend, kill or send programs to background, bring programs into foreground, and direct the user input to the [[Linux_General_Concepts#Foreground_Process|foreground process]] only. The TTY subsystem implements these features in the [[#TTY_Driver|TTY driver]].


=Components=
=<span id='Components'></span>TTY Device Components=


The TTY subsystem has several kernel components, listed below. Together these are known as a "TTY device", or sometimes just "TTY". Each TTY has a corresponding character device under /dev. When a user logs in on a particular TTY, that user must become the owner of the device file. The actual ownership is set by the [[login]] programs that runs with root privileges.
The TTY subsystem has several kernel components, listed below. Together these are known as a "TTY device", or sometimes just "TTY". Each TTY has a corresponding character device under /dev. When a user logs in on a particular TTY, that user must become the owner of the device file. The actual ownership is set by the [[login]] programs that runs with root privileges.

Revision as of 00:28, 3 May 2018

External

Internal

Overview

"TTY" is a Linux subsystem that provides the conduit through which keyboard strokes captured while the focus is in a terminal such as iTerm2 or xterm are turned into the right characters and delivered to UNIX processes. At the same time, the TTY subsystem funnels the process' generated output back to the terminal. The name comes from "teletype", which used to be electro-mechanical machines that read keyboard entires, turned them into electrical signals and sent them across the wire to to other teletypes.

TTY Functions

Line Editing

TTY subsystem provide line editing services, where a backspace key actually removes the last typed character from an internal editing buffer, instead of being sent to the user process. This functionality is implemented by a component known as line discipline. Line discipline also contain options for character echoing, automatic conversion between CR and LF. User processes have the choices of disabling this functionality, by putting the line discipline in "raw" mode, instead of the default "cooked" (or "canonical") mode. The kernel provides several line disciplines, but only one is attached to a given serial device at a time.

Session Management

TTY session management allows one user to interact with multiple processes running simultaneously in user space, one at a time. This includes the capability to suspend, kill or send programs to background, bring programs into foreground, and direct the user input to the foreground process only. The TTY subsystem implements these features in the TTY driver.

TTY Device Components

The TTY subsystem has several kernel components, listed below. Together these are known as a "TTY device", or sometimes just "TTY". Each TTY has a corresponding character device under /dev. When a user logs in on a particular TTY, that user must become the owner of the device file. The actual ownership is set by the login programs that runs with root privileges.

What are /dev/tty, /dev/tty0, ... /dev/tty63

Line Discipline

A kernel-level component providing line editing capabilities.

TTY Driver

The TTY Driver is a kernel component that implements session management. The TTY driver does not have an execution context - it has data fields and methods, but the data gets updated only if the methods get called by a process or a kernel interrupt handler.

Terminal Emulator

https://en.wikipedia.org/wiki/Terminal_emulator

A terminal emulator can be implemented in kernel - as it is the case for the Linux console, or in user space, as it is the case for text-based user interfaces such as iTerm2 or xterm. The need to move the terminal emulation in user space, while still keeping the TTY subsystem that provides session management and line discipline, led to the development of pseudo terminals.

Pseudo Terminals

https://en.wikipedia.org/wiki/Pseudoterminal

A pseudoterminal ("pseudo TTY" or "PTY") is a pair of pseudo-devices (a master and a slave) that provide a communication channel. They emulate a physical computer text terminal. Writing to the master is exactly like typing on a terminal, thus the master pseudo-device can be thought of a physical computer text terminal.

Console