'Can I make epoll_wait() to watch the same fd number which is newly opened, without re-calling epoll_ctl()?

For example, select() will watch any file descriptor that is stored in FD_SET parameter. That means, if I close one of fd in the FD_SET and open new fd for the same fd number, select() will work for the new fd(but same fd number).

But for epoll_wait(), this seems to not work. If I close the fd which is registered to the epoll fd through epoll_ctl() and re-open the new fd for the same number, epoll_wait() will break.

Can I force epoll_wait() to watch new fd(but same fd number) without re-calling epoll_ctl()?

PSA

The reason why I don't simply call epoll_ctl() again is that I'm working on injection library so I cannot track all epoll fds for its registered fds.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source