From: Collin Funk Date: Thu, 13 Mar 2025 01:55:26 +0000 (-0700) Subject: dup3: Fix behavior for equal file descriptors on Haiku. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1a2bb33101610bb157192999e34170908c62a3e8;p=gnulib.git dup3: Fix behavior for equal file descriptors on Haiku. * lib/dup3.c (dup3) [__HAIKU__]: Set errno to EINVAL and return -1 if both file descriptors are equal. * doc/posix-functions/dup3.texi: Document the Haiku bug. --- diff --git a/ChangeLog b/ChangeLog index f18bf403b9..a32123ed99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-03-12 Collin Funk + + dup3: Fix behavior for equal file descriptors on Haiku. + * lib/dup3.c (dup3) [__HAIKU__]: Set errno to EINVAL and return -1 if + both file descriptors are equal. + * doc/posix-functions/dup3.texi: Document the Haiku bug. + 2025-03-10 Bruno Haible quotearg: Avoid undefined behaviour. diff --git a/lib/dup3.c b/lib/dup3.c index d1ebb0d88c..2d5d51a769 100644 --- a/lib/dup3.c +++ b/lib/dup3.c @@ -1,5 +1,5 @@ /* Copy a file descriptor, applying specific flags. - Copyright (C) 2009-2024 Free Software Foundation, Inc. + Copyright (C) 2009-2025 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -46,8 +46,10 @@ dup3 (int oldfd, int newfd, int flags) { have_dup3_really = 1; /* On NetBSD dup3 is a no-op when oldfd == newfd, but we are - expected to fail with error EINVAL. */ -# ifdef __NetBSD__ + expected to fail with error EINVAL. + + Likewise on Haiku. */ +# if defined __NetBSD__ || defined __HAIKU__ if (newfd == oldfd) { errno = EINVAL;