Hi Collin,
> How does this look? Passes tests on NetBSD 10.00.
The position in the code is right.
Only the comment is confusing me:
> + /* On NetBSD dup3 is a no-op when oldfd == newfd, but we expect
> + an error with errno == EINVAL. */
(What is "we", and who expects something from whom?)
I would find it less confusing if written like this:
/* On NetBSD dup3 is a no-op when oldfd == newfd, but we are
expected to return -1 with errno == EINVAL. */
or
/* On NetBSD dup3 is a no-op when oldfd == newfd, but we are
expected to fail with error EINVAL. */
> Should I report this to the NetBSD people? I guess it isn't
> standardized so they are free to do as they wish.
Ideally every bug that we find in any *BSD should be reported. It's
mostly a question of time, and of likelihood that they fix it.
In this case, the argument that "look, FreeBSD and OpenBSD do it right [1][2]"
is stronger than the argument "you do it differently than glibc, and glibc
is right" that we could use to argue w.r.t. other bugs.
> [1] https://man.freebsd.org/cgi/man.cgi?query=dup3&sektion=3
> [2] https://man.openbsd.org/dup.2
Bruno