]> Savannah Git Hosting - gnulib.git/commitdiff
dup3: Fix behavior for equal file descriptors on Haiku.
authorCollin Funk <collin.funk1@gmail.com>
Thu, 13 Mar 2025 01:55:26 +0000 (18:55 -0700)
committerBruno Haible <bruno@clisp.org>
Tue, 1 Apr 2025 14:31:37 +0000 (16:31 +0200)
* 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.

ChangeLog
doc/posix-functions/dup3.texi
lib/dup3.c

index 329f4e424e91ece86b3f49cad8118f2cf32fd2ac..0a7c7f1dd7ba55dc2b8765402cf98dabdd971605 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-03-12  Collin Funk  <collin.funk1@gmail.com>
+
+       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  <bruno@clisp.org>
 
        quotearg: Avoid undefined behaviour.
index e7e4a507d0cd6066e7884a1edcfab2dced3772f3..3e9bd79fb011a224b1dd8e26339e0f10374e28f1 100644 (file)
@@ -22,7 +22,8 @@ Cygwin 1.7.25.
 @item
 This function mistakenly succeeds when given two equal file descriptors on some platforms:
 @c https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=58266
-NetBSD 10.0.
+@c https://dev.haiku-os.org/ticket/19476
+NetBSD 10.0, Haiku.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 70c55990b0b04d89adf0fbc2995225331ddce89e..2d5d51a7699eef451a97929ed025a32789275027 100644 (file)
@@ -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;