Imagine having a library that starts a server socket and manages an epoll fd with all clients. Since everything should be non blocking, control is passed to the user which may want to do a select on different fds, including the one that notifies the library.

Currently the user specifies callbacks. Then the user may call the service routine which evaluates the epoll and invokes those callbacks, to avoid constantly calling the service routine and instead do other things the user may want to wait on the epoll fd.

What is the proper way to expose a fd to the user without exposing the epoll fd ? For me a better solution would be to create a second, read-only file descriptor which becomes readable if the epoll becomes readable. Is this possible?

I am aware of a possible solution using a service thread but I would prefer if I could do this without adding complexity due to synchronization.

Another possible solution would be a eventfd and a thread which polls the epoll fd and then triggers the eventfd. But this seems to be over the top.