]> 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:49:31 +0000 (16:49 +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
lib/dup3.c

index f18bf403b9da8520f1bd0623f44a374405623a35..a32123ed9977d444ac1e3d99f998be66ae010d6a 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 d1ebb0d88ca758f9804f8f752e5228c93cfe068f..2d5d51a7699eef451a97929ed025a32789275027 100644 (file)
@@ -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;