Is it valid to add a file descriptor to epoll with epoll_event.events set to zero? What can be expected to happen when calling epoll_wait? See abridged example:
struct epoll_event event = {};
event.data.fd = fd;
event.events = 0;
epoll_ctl(efd, EPOLL_CTL_ADD, fd, &event);
epoll_wait(efd, &event, 1, -1);
What semantics can I rely on from the epoll_wait call in this instance? Are there any events that are still delivered even when events = 0?
It should be valid, and the EPOLLERR
and EPOLLHUP
are always included even if you're not requesting them, so setting events = 0
will still respond on those 2 events.
Remember to check the return value of epoll_ctl
though.
The documentation states:
The events member is a bit mask composed by ORing together zero or more of the following available event types:
EPOLLERR Error condition happened on the associated file descriptor. This event is also reported for the write end of a pipe when the read end has been closed. epoll_wait(2) will always report for this event; it is not nec‐ essary to set it in events.
EPOLLHUP Hang up happened on the associated file descriptor. epoll_wait(2) will always wait for this event; it is not necessary to set it in events.