Re: [PATCH v2] tools/nolibc: avoid error in dup2() if old fd equals new fd

From: Willy Tarreau
Date: Sat Aug 23 2025 - 06:18:58 EST


On Wed, Aug 20, 2025 at 10:29:27AM +0200, Thomas Weißschuh wrote:
> dup2() allows both 'old' and 'new' to have the same value, which dup3()
> does not. If libc dup2() is implemented through the dup3() system call,
> then it would incorrectly fail in this case.
>
> Avoid the error by handling old == new explicitly.
>
> Fixes: 30ca20517ac1 ("tools headers: Move the nolibc header from rcutorture to tools/include/nolibc/")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>

Good, LGTM!

Acked-by: Willy Tarreau <w@xxxxxx>

Willy