Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
tty(7) OSS System Calls Reference Manual
VMIN=0, VTIME=0
In this case, either the number of requested bytes or the number
of currently available bytes is returned, depending on which is
less. The read() function call returns 0 (zero) if no data was
read.
Canonical mode is entered by setting the ICANON flag of the c_lflag field in the terminal’s ter-
mios structure. Other input processing is performed according to the other flags set in the c_iflag
and c_lflag fields.
Input Editing
A terminal ordinarily operates in full-duplex mode. Characters can be typed at any time, even
while output is occurring. Characters are lost only when the system’s character input buffers
become completely overrun, which is rare, or when the user has accumulated the maximum
allowed number of input characters (MAX_INPUT/2) that have not yet been read by some pro-
gram. Currently this limit is 255 characters.
Input characters are normally accepted in either even or odd parity with the parity bit being
stripped off before the character is given to the program. The ISTRIP mask of the c_iflag field
controls whether the parity bit is stripped (ISTRIP set) or not stripped (ISTRIP not set). By set-
ting the PARENB flag in the c_cflag field and either setting (or not setting) the PARODD flag, it
is possible to have input characters with even or odd parity discarded or marked (see Input
Modes, later in this reference page).
Input characters are normally echoed by putting them in an output queue as they arrive. This can
be disabled by clearing the ECHO bit in the c_lflag word using the tcsetattr( ) function.
In canonical mode, terminal input is processed in units of lines. A program attempting to read is
normally suspended until an entire line is received (however, see the description of the
SIGTTIN signal under Terminal Access Control, later in this reference page). No matter how
many characters are requested in the read call, at most one line is returned. It is not, however,
necessary to read a whole line at once; any number of characters can be requested in a read, even
one, without losing information. In read() requests, the O_NONBLOCK flag affects the read
operation.
If the O_NONBLOCK flag is not set, a read() request is blocked until either data or a signal is
received. If the O_NONBLOCK flag is set, the read() request is not blocked and one of the fol-
lowing situations occurs:
• Some data might have been typed, but there might or might not be enough data to satisfy
the entire read() request. In either case, the read() function returns the data available,
returning the number of bytes of data it read.
• If there is no data for the read operation, the read() function returns the value -1 with an
error value of [EAGAIN].
During input, line editing is normally done with the erase special control character (VERASE)
logically erasing the last character typed and the kill special control character (VKILL) logically
erasing the entire current input line. These characters never erase beyond the beginning of the
current input line or an End-of-File (VEOF) character. These characters, along with the other
special control characters, can be entered literally by preceding them with the literal-next charac-
ter (VLNEXT,
for which the default value is <ˆV>).
The drivers normally treat either a newline character (\n), End-of-File character (VEOF), or
End-of-Line character (VEOL) as terminating an input line, echoing a return and a linefeed. If
the ICRNL mode is set in the c_iflag word of the termios structure, then carriage returns are
translated to newline characters on input and are normally echoed as carriage return-linefeed
sequences. If ICRNL is not set, this processing for carriage return is disabled; it is simply
11−72 Hewlett-Packard Company 527186-023