Line disciplines
A terminal file is used like any other file in the system in that it can
be opened, read, and written to using standard system calls. For each
existing terminal file, there is a software processing module called a
line discipline is associated with it. The line discipline essentially
glues the low level device driver code with the high level generic inter-
face routines (such as read(2) and write(2)), and is responsible for
implementing the semantics associated with the device. When a terminal
file is first opened by a program, the default line discipline called the
termios line discipline is associated with the file. This is the primary
line discipline that is used in most cases and provides the semantics
that users normally associate with a terminal. When the termios line
discipline is in effect, the terminal file behaves and is operated
according to the rules described in termios(4). Please refer to that man
page for a full description of the terminal semantics. The operations
described here generally represent features common across all line
disciplines, however some of these calls may not make sense in conjunc-
tion with a line discipline other than termios, and some may not be sup-
ported by the underlying hardware (or lack thereof, as in the case of
ptys).