In perl.git, the branch smoke-me/POSIX-sleep has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/619b23d8bef7e6c9cd2add81531caff32eea0e6d?hp=3e0b9c79bc9b7c8676e49623a92bee2cf47aa3df>

- Log -----------------------------------------------------------------
commit 619b23d8bef7e6c9cd2add81531caff32eea0e6d
Author: Nicholas Clark <[email protected]>
Date:   Fri Dec 9 13:09:07 2011 +0100

    Provide the correct POSIX return value for POSIX::dup2() on Win32.
    
    Microsoft, in their wisdom, chose to ignore the POSIX spec when implementing
    their dup2(), and have theirs return 0 on success, instead of the file
    descriptor. It seems that no other vendor is this, um, "special", so code
    the exception directly, as we don't run Configure on Win32, so there's 
little
    point probing for this.
-----------------------------------------------------------------------

Summary of changes:
 ext/POSIX/POSIX.xs |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index e8ac771..2b2055d 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -1466,6 +1466,17 @@ SysRet
 dup2(fd1, fd2)
        int             fd1
        int             fd2
+    CODE:
+#ifdef WIN32
+       /* RT #98912 - More Microsoft muppetry - failing to actually implemented
+          the well known documented POSIX behaviour for a POSIX API.
+          http://msdn.microsoft.com/en-us/library/8syseb29.aspx   */
+       RETVAL = dup2(fd1, fd2) == -1 ? -1 : fd2;
+#else
+       RETVAL = dup2(fd1, fd2);
+#endif
+    OUTPUT:
+       RETVAL
 
 SV *
 lseek(fd, offset, whence)

--
Perl5 Master Repository

Reply via email to