bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tweak test-dup2


From: Eric Blake
Subject: Re: tweak test-dup2
Date: Mon, 24 Aug 2009 22:08:23 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Bruno Haible <bruno <at> clisp.org> writes:

> Let me know if you find these tweaks unreasonable. The first hunk is to
> ensure that even if a non-empty test-dup2.tmp existed before the test, it
> will not disturb the test.

Looks good to me.  Unfortunately...

> +  errno = 0;
> +  ASSERT (dup2 (fd, 10000000) == -1);
> +  ASSERT (errno == EBADF);

...this test exposes a bug on cygwin 1.5.x (which fails with EMFILE); and 
further testing showed that cygwin 1.5.x fcntl(0,F_DUPFD,10000000) also has a 
bug, failing with EBADF instead of the required EINVAL (why dup2 must fail with 
EBADF when fcntl fails with EINVAL is beyond me).

The following patch clears up this issue, and a related compilation warning in 
pipe2.c.


From: Eric Blake <address@hidden>
Date: Mon, 24 Aug 2009 16:00:44 -0600
Subject: [PATCH] dup2, pipe2: fix some recent test failures on cygwin 1.5.x

* lib/pipe2.c (includes): Add binary-io.h.
* lib/dup2.c (rpl_dup2): Correct buggy errno value.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog   |    6 ++++++
 lib/dup2.c  |    3 +++
 lib/pipe2.c |    2 ++
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 21e02a2..0b8e2f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-24  Eric Blake  <address@hidden>
+
+       dup2, pipe2: fix some recent test failures on cygwin 1.5.x
+       * lib/pipe2.c (includes): Add binary-io.h.
+       * lib/dup2.c (rpl_dup2): Correct buggy errno value.
+
 2009-08-23  Bruno Haible  <address@hidden>

        * lib/dup3.c: Include <string.h>.
diff --git a/lib/dup2.c b/lib/dup2.c
index 6d61829..6b6f45d 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -57,6 +57,9 @@ rpl_dup2 (int fd, int desired_fd)
   result = dup2 (fd, desired_fd);
   if (result == 0)
     result = desired_fd;
+  /* Correct a cygwin 1.5.x errno value.  */
+  else if (result == -1 && errno == EMFILE)
+    errno = EBADF;
   return result;
 }

diff --git a/lib/pipe2.c b/lib/pipe2.c
index d3b612d..7def1b1 100644
--- a/lib/pipe2.c
+++ b/lib/pipe2.c
@@ -23,6 +23,8 @@
 #include <errno.h>
 #include <fcntl.h>

+#include "binary-io.h"
+
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 /* Native Woe32 API.  */

-- 
1.6.3.2







reply via email to

[Prev in Thread] Current Thread [Next in Thread]