Re: Kqueues and fork

Gleb Popov <[email protected]> Fri, 29 Aug 2025 17:55:36 +0300
Newsgroups gmane.os.freebsd.architechture
Message-ID <CALH631nzkKs4eL5drv5FXupifD9U0CORqE1N8sfefWG5qGPT_Q@mail.gmail.com>
On Fri, Aug 29, 2025 at 5:27 PM Konstantin Belousov <[email protected]> wrote:
>
> Then why don't you just open another kqueue in the child, for the
> kqueue-based implementation?  If wanted, you can dup2() it into the
> same fd as the parent kqueue fd.

If I understand it correctly, it'd require me to either

1. In the every pollable set method first check if kqfd is actually a
live kqueue fd. That'd mean an extra fcntl(fd, F_KINFO) on each call
2. Add a new pollable_set_rearm_after_fork method and put a call to it
after all forks in the code base.

Both of these solutions seem less optimal than KQUEUE_CPONFORK, which
allows pollable-set-kqueue to be a self-contained implementation.