frexp, frexp-nolibm: Move AC_LIBOBJ invocations to module description.
[pspp] / lib / dup2.c
index 9b6a8f6321bd78f3e598fc0a0ce5e80a4194c705..e00dc7b2e3c5f2789bc6a578a5f45be67871a2ef 100644 (file)
@@ -1,6 +1,6 @@
 /* Duplicate an open file descriptor to a specified file descriptor.
 
-   Copyright (C) 1999, 2004-2007, 2009-2010 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2004-2007, 2009-2011 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -52,13 +52,17 @@ rpl_dup2 (int fd, int desired_fd)
         }
       return fd;
     }
-  /* Some mingw versions also return the wrong value if desired_fd is
-     negative but not -1.  */
+  /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
+     http://bugs.winehq.org/show_bug.cgi?id=21289 */
   if (desired_fd < 0)
     {
       errno = EBADF;
       return -1;
     }
+# elif !defined __linux__
+  /* On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC.  */
+  if (fd == desired_fd)
+    return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
 # endif
   result = dup2 (fd, desired_fd);
 # ifdef __linux__