- 论坛徽章:
- 4
|
The set of file descriptors to be monitored is specified in the fds argument, which is an array of structures of
the following form:
struct pollfd {
int fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
The caller should specify the number of items in the fds array in nfds.
The field fd contains a file descriptor for an open file. If this field is negative, then the corresponding
events field is ignored and the revents field returns zero. (This provides an easy way of ignoring a file
descriptor for a single poll() call: simply negate the fd field.)
The field events is an input parameter, a bit mask specifying the events the application is interested in for the
file descriptor fd. If this field is specified as zero, then all events are ignored for fd and revents returns
zero.
The field revents is an output parameter, filled by the kernel with the events that actually occurred. The bits
returned in revents can include any of those specified in events, or one of the values POLLERR, POLLHUP, or POLL-
NVAL. (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, then poll() blocks
until one of the events occurs. |
|