Section 2.10. Terminals

   


2.10. Terminals

Historically, users interacted with the system using terminals connected to the computer through hardwired lines. Although hardwired terminals are largely a footnote in history, the character processing done for keyboard I/O is still important. The most common type of user session in FreeBSD uses a pseudo-terminal. The pseudo-terminal is built from a device pair, termed the master and slave devices. The slave device provides to a process an interface identical to that historically provided by a hardware device. However, instead of being associated with a hardware device to read and write characters, the slave device has another process manipulating it through the master half of the pseudo-terminal. That is, anything written on the master device is provided to the slave device as input, and anything written on the slave device is presented to the master device as input. Pseudo-terminals are used by the X-windows terminal emulator, xterm, as well as the common remote-login programs such as ssh and telnet.

Terminals support the standard system I/O operations, as well as a collection of terminal-specific operations to control input-character editing and output delays. The character processing is handled by a line discipline. The default line discipline is selected when a terminal is being used for an interactive login. The line discipline is run in canonical mode; input is processed to provide standard line-oriented editing functions, and input is presented to a process on a line-by-line basis.

Screen editors and programs that communicate with other computers generally run in noncanonical mode (also commonly referred to as raw mode or character-at-a-time mode). In this mode, input is passed through to the reading process immediately and without interpretation. All special-character input processing is disabled, no erase or other line editing processing is done, and all characters are passed to the program that is reading from the terminal.

It is possible to configure the terminal in thousands of combinations between these two extremes. For example, a screen editor that wanted to receive user interrupts asynchronously might enable the special characters that generate signals and enable output flow control but otherwise run in noncanonical mode. All other characters would be passed through to the process uninterpreted.

On output, the terminal handler provides simple formatting services, including the following.

  • Converting the line-feed character to the two-character carriage-return-line-feed sequence

  • Expanding tabs

  • Displaying echoed nongraphic ASCII characters as a two-character sequence of the form "^C" (i.e., the ASCII caret character followed by the ASCII character that is the character's value offset from the ASCII "@" character).

Each of these formatting services can be disabled individually by a process through control requests.


   
 


The Design and Implementation of the FreeBSD Operating System
The Design and Implementation of the FreeBSD Operating System
ISBN: 0201702452
EAN: 2147483647
Year: 2003
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net