简体   繁体   中英

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM