+poll(2) is a variation on the theme of __select__. It specifies an array of ''nfds'' structures of type

+ struct pollfd {

+ int fd; /* file descriptor */

+ short events; /* requested events */

+ short revents; /* returned events */

+ };

-__poll__
is a variation on
the theme
of __select
__. It

-specifies an array
of ''nfds
'' structures
of

-type

+and a ''timeout'' in milliseconds. A negative value means infinite timeout. The field ''fd'' contains a file descriptor for an open file. The field ''events''
is an input parameter,
a bitmask specifying the events the application is interested in. The field ''revents'' is an output parameter, filled by the kernel with
the events that actually occurred, either
of the type requested, or of one of the types
__POLLERR__ or __POLLHUP__ or __POLLNVAL
__. (These three bits are meaningless in the ''events'' field, and will be set in the ''revents'' field whenever the corresponding condition is true.) If none
of the events requested (and no error) has occurred for any of the file descriptors, the kernel waits for
''timeout
'' milliseconds for one
of these events to occur. The following possible bits in these masks are defined in '<sys/poll.h>'

+ #define POLLIN 0x0001 /* There is data to read */

+ #define POLLPRI 0x0002 /* There is urgent data to read */

+ #define POLLOUT 0x0004 /* Writing now will not block */

+ #define POLLERR 0x0008 /* Error condition */

+ #define POLLHUP 0x0010 /* Hung up */

+ #define POLLNVAL 0x0020 /* Invalid request: fd not open */

- struct pollfd {

-int fd; /* file descriptor */

-short events; /* requested events */

-short revents; /* returned events */

-};

-and a ''timeout'' in milliseconds. A negative value means infinite timeout. The field ''fd'' contains a file descriptor for an open file. The field ''events'' is an input parameter
, a bitmask specifying the events the application is interested in. The field ''revents'' is an output parameter, filled by the kernel with the events that actually occurred, either of the type requested
, or of one of the types
__POLLERR
__ or
__POLLHUP
__ or
__POLLNVAL
__. (These three bits
are meaningless in the ''events'' field, and will be set in the ''revents'' field whenever the corresponding condition is true
.) If none of the events requested (and no error) has occurred for any of the file descriptors, the kernel waits for ''timeout'' milliseconds for one of these events to occur. The following possible bits in these masks are defined in ''

Please note that any user can change the contents of pages on this site,
and therefore the Waikato Linux Users Group can offer no assurances that
the information is correct, and the information on this site is not
necessarily the opinion of the Waikato Linux Users Group, or any of its
members. If you have any complaints about the contents of this page,
please do not hesitate to contact the Waikato Linux Users Group, or, click
the Edit button!

Unless otherwise noted, all pages on this site are licensed under the
WlugWikiLicense.