1 #include <sys/epoll.h>
2 #include <stdio.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <string.h>
7 #include <sys/uio.h>
8
9 int main() {
10 struct epoll_event event ;
11 int ret,fd, epfd ;
12
13 fd = open("doc", O_RDONLY);
14 if( fd < 0 )
15 perror("open");
16
17 event.data.fd = fd ;
18 event.events = EPOLLIN|EPOLLOUT ;
19
20 epfd = epoll_create(50);
21 printf("%d", epfd );
22
23 if( epfd < 0 )
24 perror("epoll_create");
25
26 ret = epoll_ctl( epfd, EPOLL_CTL_ADD, fd, &event ) ;
27 if( ret < 0 )
28 perror("epoll_ctl");
29
30 }
编译此代码时,没有错误。gcc -o epoll epoo.c
但是当我尝试执行程序“epoll”时,我收到了错误消息
epoll_ctl:不允许操作。
我试图将“doc”文件的模式更改为 0777,但它不起作用。
问题是什么?谢谢 :)