poll.2 (2010 09)

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 descrip-
tors 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.
Arguments
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 com-
binations of condition flags. The following condition flags are defined:
POLLIN Data can be read without blocking. For streams, this flag means that a mes-
sage that is not high priority is at the front of the stream head read queue.
This message 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
mutually exclusive with POLLOUT, since a stream cannot be written to after a
hangup occurs. This flag 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 nor-
mal 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: September 2010 1 Hewlett-Packard Company 1

Summary of content (4 pages)