epoll file descriptor operations
I'm trying to wrap my head around epoll in Linux.
The normal operation seems to be:// Create the epoll_fd
int epoll_fd = epoll_create(10);
...
// Add file descriptors to it
struct epoll_event ev = {0};
ev.events |= EPOLLIN;
ev.data.pt开发者_运维技巧r = ...;
/* for brevity, I don't do error checking here */
epoll_ctl(epoll_fd, EPOLL_CTL_ADD, some_fd, &ev);
...
// Wait for IO events
struct epoll_event events[10];
int num_events = epoll_wait(epoll_fd, events, 10, -1);
// Now handle the events
...
My question is this: given the epoll_fd
seems to be a regular file descriptor, are there any other file operations that I can do with it, besides the three epoll function calls?
From the man page:
Q3 Is the epoll fd itself poll/epoll/selectable?
A3 Yes.
You can poll(2)
your epoll_fd
itself :)
精彩评论