can we use the same fd in multiple epollfds? I mean one epoll instance for catching EPOLLIN, one epoll instance for catching EPOLLOUT.

for example:

int fd = ... // the file descriptor
int epoll_reader = epoll_create1(0); // first epoll instance for reading
int epoll_writer = epoll_create1(0); // second epoll instance for writing

for reading I need these flags: EPOLLIN | EPOLLET

but for writing I don't want it to be edge-triggered, I want it to be level-triggered and pass only EPOLLOUT

registering for reader:

struct epoll_event ev;
ev.data.fd = fd;
ev.events = EPOLLIN | EPOLLET;
epoll_ctl(epoll_reader, EPOLL_CTL_ADD, fd, &ev);

registering for writer:

struct epoll_event ev;
ev.data.fd = fd;
ev.events = EPOLLOUT;
epoll_ctl(epoll_writer, EPOLL_CTL_ADD, fd, &ev);

the reason for doing this is to catch EPOLLIN as edge-trigger and catch EPOLLOUT as level-trigger.

as my code base got too large I cannot modify it and test it, I must make sure to do any changes on the code.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.