dup2 is fully tested if the cloexec module is in use, but it is
also used in a number of modules where dragging in cloexec is
over the top for just using dup2 to test whether an fd is valid.
* modules/cloexec (Configure.ac): Set witness.
* modules/dup2-tests (Depends-on): Drop cloexec.
* tests/test-dup2.c (main): Skip portion of test if cloexec module
not present.
Suggested by Bruno Haible.
Signed-off-by: Eric Blake <ebb9@byu.net>
+2009-12-28 Eric Blake <ebb9@byu.net>
+
+ test-dup2: reduce dependencies
+ * modules/cloexec (Configure.ac): Set witness.
+ * modules/dup2-tests (Depends-on): Drop cloexec.
+ * tests/test-dup2.c (main): Skip portion of test if cloexec module
+ not present.
+ Suggested by Bruno Haible.
+
2009-12-26 Bruno Haible <bruno@clisp.org>
Remove an unneeded dependency.
2009-12-26 Bruno Haible <bruno@clisp.org>
Remove an unneeded dependency.
+gl_MODULE_INDICATOR([cloexec])
#include <fcntl.h>
#include "binary-io.h"
#include <fcntl.h>
#include "binary-io.h"
+
+#if GNULIB_CLOEXEC
+# include "cloexec.h"
+#endif
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* Get declarations of the Win32 API functions. */
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* Get declarations of the Win32 API functions. */
ASSERT (read (fd, buffer, 1) == 1);
ASSERT (*buffer == '2');
ASSERT (read (fd, buffer, 1) == 1);
ASSERT (*buffer == '2');
/* Any new fd created by dup2 must not be cloexec. */
ASSERT (close (fd + 2) == 0);
ASSERT (dup_cloexec (fd) == fd + 1);
/* Any new fd created by dup2 must not be cloexec. */
ASSERT (close (fd + 2) == 0);
ASSERT (dup_cloexec (fd) == fd + 1);
ASSERT (!is_inheritable (fd + 1));
ASSERT (dup2 (fd + 1, fd + 2) == fd + 2);
ASSERT (is_inheritable (fd + 2));
ASSERT (!is_inheritable (fd + 1));
ASSERT (dup2 (fd + 1, fd + 2) == fd + 2);
ASSERT (is_inheritable (fd + 2));
/* On systems that distinguish between text and binary mode, dup2
reuses the mode of the source. */
/* On systems that distinguish between text and binary mode, dup2
reuses the mode of the source. */