epoll_wait -- wait for I/O events on an epoll file descriptor


#include <sys/epoll.h>

int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout);


The interface epoll_wait() shall wait for events on the epoll file descriptor specified by the parameter epfd.

Upon success, the output parameter events shall refer to an area of memory containing epoll_event structures available to the caller. The data members of these structures shall contain the data set by the user with the interface epoll_ctl(). The events members shall contain the event bit field that was returned.

The parameter maxevents shall specify the maximum number of events that epoll_wait() may return in the output parameter events. The value of this parameter should be greater than 0.

The parameter timeout shall specify the maximum number of milliseconds that epoll_wait() shall wait for events. If the value of this parameter is 0, then epoll_wait() shall return immediately, even if no events are available, in which case the return code shall be 0. If the value of timeout is -1, then epoll_wait() shall block until either a requested event occurs or the call is interrupted.

Return Value

On success, epoll_wait() shall return the number of file descriptors that are ready for the I/O that was requested, or else 0 if no descriptors became ready during timeout.

On failure, epoll_wait() shall return -1 and set errno as follows.



The parameter epfd is not a valid file descriptor.


The area of memory referenced by the parameter events cannot be accessed with write permissions.


The call was interrupted by a signal handler before the timeout expired or any requested event took place.


The parameter epfd is not a valid epoll file descriptor, or else the parameter maxevents is less than or equal to 0.

See Also

close(), epoll_ctl(), epoll_create(), poll().