HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)
p
poll(2) poll(2)
POLLWRNORM Same as POLLOUT
POLLWRBAND
Priority data (priority band > 0) can be written without being blocked by flow
control. Only previously written bands are checked.
POLLMSG A M_SIG or M_PCSIG message specifying SIGPOLL
has reached the front of
the stream head read queue.
The conditions indicated by
POLLNORM and POLLOUT
are true if and only if at least one byte of data can
be read or written without blocking. The exception is regular files, which always poll true for
POLLNORM
and POLLOUT. Also, streams return POLLNORM
in revents even if the available message is of zero
length.
The condition flags
POLLERR, POLLHUP, and
POLLNVAL are always set in revents if the conditions
they indicate are true for the specified file descriptor, whether or not these flags are set in
events.
For each call to
poll(), the set of reportable conditions for each file descriptor consists of those conditions
that are always reported, together with any further conditions for which flags are set in
events. If any
reportable condition is true for any file descriptor,
poll() returns with flags set in revents for each
true condition for that file descriptor.
If no reportable condition is true for any of the file descriptors,
poll() waits up to timeout milliseconds
for a reportable condition to become true. If, in that time interval, a reportable condition becomes true for
any of the file descriptors,
poll() reports the condition in the file descriptor’s associated
revents
member and returns. If no reportable condition becomes true, poll() returns without setting any
revents bit masks.
If the timeout parameter is a value of −1, poll() does not return until at least one specified event has
occurred. If the value of the timeout parameter is 0, poll() does not wait for an event to occur but
returns immediately, even if no specified event has occurred. The behavior of poll() is not affected by
whether the
O_NONBLOCK flag is set on any of the specified file descriptors.
RETURN VALUE
Upon successful completion, poll() returns a nonnegative value. If the call returns 0, poll() has
timed out and has not set any of the
revents bit masks. A positive value indicates the number of file
descriptors for which poll() has set the revents bit mask. If poll() fails, it returns −1 and sets
errno to indicate the error.
ERRORS
poll() fails if any of the following conditions are encountered:
[EAGAIN] Allocation of internal data structures failed. A later call to
poll() may complete
successfully.
[EINTR] A signal was delivered before any of the selected for conditions occurred or before the
time limit expired.
[EINVAL] One of the following conditions is true:
• timeout is a negative number other than −1.
• The nfds argument is less than 0, greater than
maxfiles, or greater than or
equal to MAXFUPLIM . The kernel parameter maxfiles specifies the max-
imum number of file descriptors per process (see maxfiles(5)). MAXFUPLIM
specifies the maximum number of files a process can have open at one time; it
has a value of 2048 if the resource limit RLIMIT_NOFILE for a process is less
than or equal to 2048.
• One of the specified file descriptor refers to a stream or mux that is linked down-
stream from a mux.
[EFAULT] The fds parameter in conjunction with the nfds parameter addresses a location out-
side of the allocated address space of the process. Reliable detection of this error is
implementation-dependent.
EXAMPLES
Wait for input on file descriptor 0:
#include <poll.h>
struct pollfd fds;
268 Hewlett-Packard Company − 2 − HP-UX 11i Version 3: February 2007