Frage

Suppose I have a already constructed epoll set, is it possible to find out if a certain fd belongs to this epoll set? And is it possible to find out from this epoll set what events a certain fd is interested in? Thanks.

War es hilfreich?

Lösung

Use epoll_ctl with the fd you want to check with the op argument EPOLL_CTL_ADD. If the fd is already registered then registration will fail with errno assigned with EEXIST.

If registration succeeds, then it is part of the epoll set so delete it from the set right away using epoll_ctl with the op argument EPOLL_CTL_DEL so that the set remains unchanged.

If you can add some more context to your problem then maybe we can come up with a better method.

Andere Tipps

You can use epoll_ctl with the file descriptor, if the file descriptor is not part of the set, epoll will return with an error: EBADF

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top