Many of the remaining functions in this section refer to the input and output queues of a terminal device. These queues implement a form of buffering within the kernel independent of the buffering implemented by I/O streams (see I/O on Streams).
The terminal input queue is also sometimes referred to as its typeahead buffer. It holds the characters that have been received from the terminal but not yet read by any process.
The size of the input queue is described by the MAX_INPUT
and
_POSIX_MAX_INPUT
parameters; see Limits for Files. You
are guaranteed a queue size of at least MAX_INPUT
, but the queue
might be larger, and might even dynamically change size. If input flow
control is enabled by setting the IXOFF
input mode bit
(see Input Modes), the terminal driver transmits STOP and START
characters to the terminal when necessary to prevent the queue from
overflowing. Otherwise, input may be lost if it comes in too fast from
the terminal. In canonical mode, all input stays in the queue until a
newline character is received, so the terminal input queue can fill up
when you type a very long line. See Canonical or Not.
The terminal output queue is like the input queue, but for output;
it contains characters that have been written by processes, but not yet
transmitted to the terminal. If output flow control is enabled by
setting the IXON
input mode bit (see Input Modes), the
terminal driver obeys START and STOP characters sent by the terminal to
stop and restart transmission of output.
Clearing the terminal input queue means discarding any characters that have been received but not yet read. Similarly, clearing the terminal output queue means discarding any characters that have been written but not yet transmitted.