HP-UX Reference (11i v3 07/02) - 7 Device (Special) Files, 9 General Information, Index (vol 10)
t
termio(7) termio(7)
Commands using this form are:
FIONREAD Returns in the integer referenced by arg the number of characters immediately read-
able from the terminal device file. This command is allowed from a background pro-
cess; however, the data itself cannot be read from a background process.
Non-blocking I/O IOCTL Commands
Non-blocking I/O is easily provided via the
O_NONBLOCK and O_NDELAY flags available in both open(2)
and fcntl(2). The commands in this section are provided for backward compatibility with previously
developed applications.
ioctl() system calls that provide a style of non-blocking I/O different from
O_NONBLOCK and O_NDELAY have the form:
ioctl (fildes, command, arg)
int *arg;
Commands using this form are:
FIOSNBIO If the integer referenced by arg is non-zero,
FIOSNBIO-style non-blocking I/O is
enabled; that is, subsequent reads and writes to the terminal device file are handled in
a non-blocking manner (see below). If the integer referenced by arg is 0,
FIOSNBIO-style non-blocking I/O is disabled.
For reads, FIOSNBIO-style non-blocking I/O prevents all read requests to that dev-
ice file from blocking, whether the requests succeed or fail. Such a read request com-
pletes in one of three ways:
• If there is enough data available to satisfy the entire request, the read completes
successfully, having read all of the data, and returns the number of characters
read;
• If there is not enough data available to satisfy the entire request, the read com-
pletes successfully, having read as much data as possible, and returns the
number of characters read;
• If there is no data available, the read returns −1 with errno set to [EWOULD-
BLOCK].
For writes,
FIOSNBIO-style non-blocking I/O prevents all write requests to that dev-
ice file from blocking, whether the requests succeed or fail. Such a write request com-
pletes in one of three ways:
• If there is enough space available in the system to buffer all the data, the write
completes successfully, having written out all of the data, and returns the
number of characters written;
• If there is not enough space in the buffer to write out the entire request, the
write completes successfully, having written as much data as possible, and
returns the number of characters written;
• If there is no space in the buffer, the write returns −1 with
errno set to
[EWOULDBLOCK].
To prohibit
FIOSNBIO-style non-blocking I/O from interfering with the
O_NONBLOCK and O_NDELAY flags (see open(2) and fcntl(2)), the functionality of
O_NONBLOCK and O_NDELAY always supersedes the functionality of FIOSNBIO-
style non-blocking I/O. This means that if either O_NONBLOCK or O_NDELAY is
set, the driver performs read requests in accordance with the definition of
O_NDELAY or O_NONBLOCK. When both O_NONBLOCK and O_NDELAY are
clear, the definition of FIOSNBIO-style non-blocking I/O applies.
The default on open of a terminal device file is that FIOSNBIO-style non-blocking
I/O is disabled.
FIOGSNBIO The integer referenced by arg is set to 1, if FIOSNBIO-style non-blocking I/O is
enabled. Otherwise, the integer referenced by arg is set to 0.
Process Group Control IOCTL Commands
The process group control features described here (except for setting and getting the delayed stop process
character) are easily implemented using the functions tcgetattr() , tcsetattr() , tcgetpgrp() ,
tcsetpgrp() , and tcsetsid() , (see tcattribute(3C), tcgetpgrp(3C), tcsetpgrp(3C), and tcgetsid(3C)
HP-UX 11i Version 3: February 2007 − 15 − Hewlett-Packard Company 223