Next: Using the Terminal Interface
Up: Terminal Control the Hard
Previous: Terminal Control the Hard
Contents
- POSIX defines a standard interface for querying and manipulating terminals. This interface is called termios and is defined in the system header file
.
- termios provides finely grained control over how Linux receives and processes input.
- From a programmer's perspective, termios is a data structure and a set of functions that manipulate it. (see man 3 termios)
- Terminals operate in one of two modes,
- canonical (or cooked) mode, in which the terminal device driver processes special characters and feeds input to a program one line at a time, (the shell is an example of an application that uses canonical mode)
- non-canonical (or raw) mode, in which most keyboard input is unprocessed and unbuffered. (the screen editor vi, uses non-canonical mode; vi receives input as it is typed and processes most special characters itself (D, for example, moves to the end of a file in vi, but signals EOF to the shell))
- The termios interface includes functions
- Attribute Control Functions; the interface includes functions for controlling terminal characteristics.
- Speed Control Functions; the first four functions set the input and output speed of a terminal device.
- Line Control Functions; the line control functions query and set various properties concerned with how, when, and if data flows to the terminal device.
- Process Control Functions; the process control functions the termios interface defines enable you to get information about the processes (programs) running on a given terminal.
- The Fig. 12.1 depicts the relationship between the hardware
model and the termios data structures.
Figure 12.1:
How the hardware model maps to the termios structure.
|
Next: Using the Terminal Interface
Up: Terminal Control the Hard
Previous: Terminal Control the Hard
Contents
Cem Ozdogan
2007-05-16