Here's from epoll(7)
Questions and answers section:
Q1
What happens if you register the same file descriptor on anepoll
instance twice?
A1
You will probably getEEXIST
. However, it is possible to add a duplicate (dup(2)
,dup2(2)
,fcntl(2)
F_DUPFD
) descriptor to the sameepoll instance
. This can be a useful technique for filtering events, if the duplicate file descriptors are registered with differentevents
masks.