Provided that:
epfd
by epoll_create
, and registered many regular file descriptors by EPOLL_CTL_ADD
.close(epfd)
The manual page does't say whether I must EPOLL_CTL_DEL
all file descriptors before close(epfd)
.
So, my question is:
Is it necessary to remove all file descriptors in the interest list before closing the epoll instance itself?
No, it's not necessary to manually remove them.
From the epoll_create(2)
manpage (emphasis added)
When all file descriptors referring to an epoll instance have been closed, the kernel destroys the instance and releases the associated resources for reuse.