HP-UX Reference (11i v3 07/02) - 7 Device (Special) Files, 9 General Information, Index (vol 10)

t
termio(7) termio(7)
from its controlling terminal will be denied. If denied and the reading process is ignoring or blocking the
SIGTTIN signal, or the process (on systems that implement vfork separately from fork) has made a call to
vfork(2) but has not yet made a call to exec(2), or the process group of the reading process is orphaned,
read() returns 1 with errno set to
EIO and no signal is sent. In all other cases where the read is
denied, the process group of the reading process will be sent a
SIGTTIN signal. The default action of the
SIGTTIN signal is to stop the process to which it is sent.
If the process is in the foreground process group of its controlling terminal, write operations are allowed
(see Writing Data and Output Processing). Attempts by a process in a background process group to write
to its controlling terminal are denied if
TOSTOP (see Local Modes) is set, the process is not ignoring and
not blocking the
SIGTTOU signal, and the process (on systems that implement vfork separately from fork)
has not made a call to vfork(2) without making a subsequent call to exec(2). If the write is denied and the
background process group is orphaned, the
write()
returns 1 with errno set to EIO. If the write is
denied and the background process group is not orphaned, the
SIGTTOU signal is sent to the process
group of the writing process. The default action of the
SIGTTOU signal is to stop the process to which it is
sent.
Certain calls that set terminal parameters are treated in the same fashion as write, except that
TOSTOP is
ignored; that is, the effect is identical to that of terminal writes when
TOSTOP is set.
Input Processing and Reading Data
A terminal device associated with a terminal device file can operate in full-duplex mode, so that data can
arrive, even while data output is occurring. Each terminal device file has an input queue associated with it
into which incoming data is stored by the system before being read by a process. The system imposes a
limit,
MAX_INPUT, on the number of characters that can be stored in the input queue. This limit is depen-
dent on the particular implementation, but is at least 256. When the input limit is reached, all saved char-
acters are discarded without notice.
All input is processed either in canonical mode or non-canonical mode (see Canonical Mode Input Process-
ing and Non-Canonical Mode Input Processing). Additionally, input characters are processed according to
the
c_iflag (see Input Modes) and c_lflag (see Local Modes) fields. For example, such processing
can include echoing, which in general means transmitting input characters immediately back to the termi-
nal when they are received from the terminal. This is useful for terminals that operate in full-duplex mode.
The manner in which data is provided to a process reading from a terminal device file depends on whether
the terminal device file is in canonical or non-canonical mode.
Another dependency is whether the O_NONBLOCK or O_NDELAY flag is set by either open(2) or fcntl(2).
If the
O_NONBLOCK and O_NDELAY flags are both clear, the read request is blocked until data is avail-
able or a signal is received. If either the O_NONBLOCK or O_NDELAY flag is set, the read request com-
pletes without blocking in one of three ways:
If there is enough data available to satisfy the entire request, read() completes successfully, having
read all of the data requested, and returns the number of characters read.
If there is not enough data available to satisfy the entire request, read() completes successfully,
having read as much data as possible, and returns the number of characters read.
If there is no data available, read() returns 1, with errno set to EAGAIN when the
O_NONBLOCK flag is set. Otherwise, (flag O_NONBLOCK is clear and O_NDELAY is set) read()
completes successfully, having read no data, and returns a count of 0.
The availability of data depends upon whether the input processing mode is canonical or non-canonical.
The following sections, Canonical Mode Input Processing and Non-Canonical Mode Input Processing,
describe each of these input processing modes.
Canonical Mode Input Processing (Erase and Kill Processing)
In canonical mode input processing, terminal input is processed in units of lines, where a line is delimited
by a new-line (NL) character, an end-of-file (EOF) character, or an end-of-line character (EOL) or (EOL2).
See Special Characters for more information on
NL, EOF, EOL, and EOL2. This means that a read request
does not return until an entire line has been typed or a signal has been received. Also, no matter how
many characters are requested in the read call, at most one line will be returned. It is not, however, neces-
sary to read a whole line at once; any number of characters can be requested in a read, even one, without
losing information.
MAX_CANON is the limit on the number of characters in a line. This limit varies with each particular
implementation, but is at least 256.
210 Hewlett-Packard Company 2 HP-UX 11i Version 3: February 2007