HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)

p
poll(2) poll(2)
NAME
poll() - monitor I/O conditions on multiple file descriptors
SYNOPSIS
#include <poll.h>
int poll(
struct pollfd fds[],
nfds_t nfds,
int timeout);
DESCRIPTION
poll() provides a general mechanism for reporting I/O conditions associated with a set of file descriptors
and for waiting until one or more specified conditions becomes true. Specified conditions include the ability
to read or write data without blocking, and error conditions.
Parameters
fds Points to an array of
pollfd structures, one for each file descriptor of interest.
nfds Specifies the number of
pollfd structures in the fds array.
timeout Specifies the maximum length of time (in milliseconds) to wait for at least one of the
specified conditions to occur.
Each
pollfd structure includes the following members:
int fd File descriptor
short events Requested conditions
short revents Reported conditions
The fd member of each pollfd structure specifies an open file descriptor. The
poll() function uses
the
events member to determine what conditions to report for this file descriptor. If one or more of
these conditions is true, poll() sets the associated revents member.
poll() ignores any pollfd structure whose fd member is negative. If the fd member of all
pollfd structures is negative, poll() returns 0 and has no other results.
The events and revents members of the pollfd structure are bit masks. The calling process sets
the events bit mask, and poll() sets the revents bit masks. These bit masks contain ORed combi-
nations of condition flags. The following condition flags are defined:
POLLIN Data can be read without blocking. For streams, this flag means that a message
that is not high priority is at the front of the stream head read queue. This mes-
sage can be of zero length.
POLLNORM Synonym for POLLIN
POLLPRI
A high priority message is available. For streams, this message can be of zero
length.
POLLOUT Data can be written without blocking. For streams, this flag specifies that nor-
mal data (not high priority or priority band > 0) can be written without being
blocked by flow control. This flag is not used for high priority data, because it
can be written even if the stream is flow controlled.
POLLERR An error has occurred on the file descriptor.
POLLHUP The device has been disconnected. For streams, this flag in revents is mutu-
ally exclusive with
POLLOUT, since a stream cannot be written to after a
hangup occurs. This ag and POLLIN, POLLPRI, POLLRDNORM , POLLRD-
BAND
, and POLLMSG are not mutually exclusive.
POLLNVAL fd is not a valid file descriptor.
POLLRDNORM A non-priority message is available. For streams, this flag means that a normal
message (not high priority or priority band > 0) is at the front of the stream head
read queue. This message can be of zero length.
POLLRDBAND A priority message (priority band > 0) is at the front of the stream head read
queue. This message can be read without blocking. The message can be of zero
length.
HP-UX 11i Version 3: February 2007 1 Hewlett-Packard Company 267