Re: Kqueues and fork

From: Gleb Popov <arrowd_at_freebsd.org>
Date: Fri, 29 Aug 2025 14:55:36 UTC
On Fri, Aug 29, 2025 at 5:27 PM Konstantin Belousov <kostikbel@gmail.com> 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.