External UNIX fd

8 views
Skip to first unread message

Eugen-Andrei Gavriloaie

unread,
May 26, 2019, 4:01:40 PM5/26/19
to libuv
We know that kqueue and epoll can be cascaded. I have a library which is available only for systems that have kqueue or epoll. Internally, this library is having a bunch of file descriptors like sockets and timers that are tested for events using epoll/kqueue. Finally, this library is exposing this epoll/kqueue fd as an unique file descriptor which designates a session. This can then be tested for events in other upper layers using epoll/kqueue. Of course, the only valid event for this cascaded unique file descriptor is the read event which informs the user of the library that something happened on that session designated by the file descriptor.

I have searched a way to convince libuv to accept a generic file descriptor and listen for read events, but I did not find such a thing.

Is there a way to tell libuv about an FD and only report back when events are happening, not actually doing any reading on it?

Best regards,
Andrei

Ben Noordhuis

unread,
May 26, 2019, 6:20:22 PM5/26/19
to li...@googlegroups.com
Yes, there is: http://docs.libuv.org/en/v1.x/poll.html

Caveat emptor: Linux lets you watch one epoll fd with another but with
kqueue fds that won't work everywhere:
http://docs.libuv.org/en/v1.x/loop.html#c.uv_backend_fd

Eugen-Andrei Gavriloaie

unread,
May 26, 2019, 8:26:13 PM5/26/19
to libuv
Hi Ben,

Thanks for pointing that out. Totally missed that type of handler for some reason. Sorry for the noise.

Interesting note about kqueue. I did not see that behavior on macOS. I’m currently using that library like that: cascading kqueue. I’ll test our stuff on FreeBSD too. These are the 2 most notable BSD-like operating systems I have on the top of my mind. Perhaps OpenBSD is worth trying as well.

Best regards,
Andrei
Reply all
Reply to author
Forward
0 new messages