epoll 文件描述符操作
我正在尝试了解 Linux 中的 epoll。
正常操作似乎是:
// 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.ptr = ...;
/* 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
...
我的问题是这样的:鉴于 epoll_fd 似乎是常规文件描述符,除了三个 epoll 函数调用之外,我还可以用它执行其他文件操作吗?
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.ptr = ...;
/* 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 手册页:
From the man page:
您可以
poll(2)
您的epoll_fd
本身:)You can
poll(2)
yourepoll_fd
itself :)