Files
Maxim Konovalov f9f4abe8c9 tests/sys/file: add tests for the lowest fd after fork
fdcopy() skips plain kqueues and close-on-fork descriptors when it
copies the table into the child.  Check that dup(2) in the child still
returns the lowest unused descriptor, both when the skipped descriptor
is the lowest free slot and when it sits above an existing hole.

Test cases:

  kqueue_no_hole      a plain kqueue is the lowest descriptor; the
                      child's dup() reuses its slot
  kqueue_two          two adjacent plain kqueues; the child's dup()
                      returns the lower one
  kqueue_above_hole   a plain kqueue sits above a closed descriptor;
                      the child's dup() returns the hole
  kqueue_cponfork     a KQUEUE_CPONFORK kqueue is copied; the child's
                      dup() returns the next slot
  clofork_no_hole     an O_CLOFORK descriptor is the lowest one; the
                      child's dup() reuses its slot
  clofork_above_hole  an O_CLOFORK descriptor sits above a closed
                      descriptor; the child's dup() returns the hole

Without 99a58803f9, kqueue_no_hole, kqueue_two and
clofork_above_hole fail.

PR:		300234
Reviewed by:	kib
MFC after:	1 week
MFC with:	99a58803f9
Co-authored-by:	Claude Code Opus 5.5
Differential Revision:	https://reviews.freebsd.org/D61124
2026-11-02 21:11:44 +00:00
..