Search code examples
clinuxepoll

Does setting an epoll_event.events bits to zero "disables" an event, like EV_DISABLE in the kqueue?


If the bits of epoll_event.events field is zeroed, does it disables the event?

The kqueue has EV_DISABLE, that

EV_DISABLE Disable the event so kevent() will not return it.
The filter itself is not disabled.

epoll_event ev;
ev.data.fd = 0; /* stdin file descriptor */
ev.events = EPOLLIN;
epoll_ctl(epollfd, EPOLL_CTL_ADD, evfd, &ev);
ev.events = 0;
epoll_ctl(epollfd, EPOLL_CTL_MOD, evfd, &ev);

So, does the above makes the stdout event not being reported to epoll_wait ?


Solution

  • No, a 0 events field doesn't disable checking the associated file descriptor for events. EPOLLHUP in particular will get returned even if it's not explicitly asked for.

    You have to remove the descriptor from the epoll interest list, and re-add it when you want to resume monitoring it.