Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 390 Vote(s) - 3.58 Average
  • 1
  • 2
  • 3
  • 4
  • 5
epoll_ctl : Operation not permitted error - c program

#1
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 }

When compiling this code, there was no errors.
gcc -o epoll epoo.c

but when i tried to execute the program 'epoll', i got the error message
> epoll_ctl:Operation not permitted.

I've tried to change the 'doc' file's mode to 0777 but it was not work.

What is the problem? Thank you :)
Reply

#2
From `epoll_ctl(2)`:

EPERM The target file fd does not support epoll.

I'm going to guess that `doc` is a regular file. Regular files are _always_ ready for `read(2)` or `write(2)` operations, thus it doesn't make sense to `epoll(7)` or `select(2)` on regular files.

If `doc` is a pipe or unix domain socket, comment here (so I know to delete my post) and amend your question so others don't make the same mistake I did. :)
Reply

#3
In this case you're opening a regular file. `epoll()`, `select()`, and `poll()` don't make sense on regular files.

If it is a pipe or socket, then:

$mkfifo doc
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through