summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-09-10 11:55:27 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2010-09-10 11:55:27 -0700
commitffb0b29997c66526985e1f4a496335d0ab4ef111 (patch)
tree855831d96cb87ac718f45362cd6bdea26cfa2ae3 /tests
parent3f322af6c93f7eb4c6ce5ceb789416aae10a50bd (diff)
downloadgnulib-ffb0b29997c66526985e1f4a496335d0ab4ef111.tar.gz
fcntl-h: define O_CLOEXEC and O_EXEC if not defined; use new defines
* doc/posix-headers/fcntl.texi (fcntl.h): Document that O_CLOEXEC is now defined to 0 if it is not defined, like other flags. Also, O_EXEC is now defined to be O_RDONLY if O_EXEC is not defined. Similarly for O_SEARCH; this last was already true, but not documented. * lib/fcntl.in.h (O_CLOEXEC): Define to 0 if not defined. * lib/dup-safer-flag.c (O_CLOEXEC): Remove now-useless #define. * lib/dup3.c, lib/pipe2.c, tests/test-dup-safer.c, tests/test-fcntl.c: Likewise. * lib/popen-safer.c (open_noinherit): Check whether O_CLOEXEC is zero, not whether it is defined. * tests/test-dup3.c, tests/test-pipe2.c (main): Likewise. * lib/progreloc.c (find_executable): Use O_EXEC rather than O_RDONLY. * lib/open.c (open): Check for O_SEARCH as well as for O_RDONLY.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-dup-safer.c3
-rw-r--r--tests/test-dup3.c4
-rw-r--r--tests/test-fcntl.c5
-rw-r--r--tests/test-pipe2.c4
4 files changed, 4 insertions, 12 deletions
diff --git a/tests/test-dup-safer.c b/tests/test-dup-safer.c
index 28f1317723..b71b6c3912 100644
--- a/tests/test-dup-safer.c
+++ b/tests/test-dup-safer.c
@@ -38,9 +38,6 @@
# define setmode(f,m) zero ()
static int zero (void) { return 0; }
#endif
-#ifndef O_CLOEXEC
-# define O_CLOEXEC 0
-#endif
/* This test intentionally closes stderr. So, we arrange to have fd 10
(outside the range of interesting fd's during the test) set up to
diff --git a/tests/test-dup3.c b/tests/test-dup3.c
index a719234103..f1e978b15d 100644
--- a/tests/test-dup3.c
+++ b/tests/test-dup3.c
@@ -75,7 +75,7 @@ main ()
{
int use_cloexec;
-#if defined O_CLOEXEC
+#if O_CLOEXEC
for (use_cloexec = 0; use_cloexec <= 1; use_cloexec++)
#else
use_cloexec = 0;
@@ -87,7 +87,7 @@ main ()
char buffer[1];
o_flags = 0;
-#if defined O_CLOEXEC
+#if O_CLOEXEC
if (use_cloexec)
o_flags |= O_CLOEXEC;
#endif
diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c
index 71dfb9869f..a181da3571 100644
--- a/tests/test-fcntl.c
+++ b/tests/test-fcntl.c
@@ -39,11 +39,6 @@ SIGNATURE_CHECK (fcntl, int, (int, int, ...));
#include "binary-io.h"
#include "macros.h"
-/* Use O_CLOEXEC if available, but test works without it. */
-#ifndef O_CLOEXEC
-# define O_CLOEXEC 0
-#endif
-
#if !O_BINARY
# define setmode(f,m) zero ()
static int zero (void) { return 0; }
diff --git a/tests/test-pipe2.c b/tests/test-pipe2.c
index bd6df7ce19..e8e5798974 100644
--- a/tests/test-pipe2.c
+++ b/tests/test-pipe2.c
@@ -92,7 +92,7 @@ main ()
#else
use_nonblocking = 0;
#endif
-#if defined O_CLOEXEC
+#if O_CLOEXEC
for (use_cloexec = 0; use_cloexec <= 1; use_cloexec++)
#else
use_cloexec = 0;
@@ -106,7 +106,7 @@ main ()
if (use_nonblocking)
o_flags |= O_NONBLOCK;
#endif
-#if defined O_CLOEXEC
+#if O_CLOEXEC
if (use_cloexec)
o_flags |= O_CLOEXEC;
#endif