diff options
author | Guido Günther <agx@sigxcpu.org> | 2013-08-04 20:34:00 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-08-04 20:34:00 +0200 |
commit | 58c2a296d9378f246f58b5abb2ec75d70ae2be78 (patch) | |
tree | 32776d58fd1e027a271b5aaaceca6d8358ea1c43 /gnulib/tests/test-posix_spawn_file_actions_addopen.c | |
parent | 97ba16c1e12111c63fd1d38814dcc46eb9affc28 (diff) |
New upstream version 1.1.1
Diffstat (limited to 'gnulib/tests/test-posix_spawn_file_actions_addopen.c')
-rw-r--r-- | gnulib/tests/test-posix_spawn_file_actions_addopen.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gnulib/tests/test-posix_spawn_file_actions_addopen.c b/gnulib/tests/test-posix_spawn_file_actions_addopen.c index c2329d4fc..a4865ca97 100644 --- a/gnulib/tests/test-posix_spawn_file_actions_addopen.c +++ b/gnulib/tests/test-posix_spawn_file_actions_addopen.c @@ -25,10 +25,25 @@ SIGNATURE_CHECK (posix_spawn_file_actions_addopen, int, #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <unistd.h> #include "macros.h" +/* Return a file descriptor that is too big to use. + Prefer the smallest such fd, except use OPEN_MAX if it is defined + and is greater than getdtablesize (), as that's how OS X works. */ +static int +big_fd (void) +{ + int fd = getdtablesize (); +#ifdef OPEN_MAX + if (fd < OPEN_MAX) + fd = OPEN_MAX; +#endif + return fd; +} + int main (void) { @@ -44,8 +59,9 @@ main (void) == EBADF); } { + int bad_fd = big_fd (); errno = 0; - ASSERT (posix_spawn_file_actions_addopen (&actions, getdtablesize (), + ASSERT (posix_spawn_file_actions_addopen (&actions, bad_fd, "foo", 0, O_RDONLY) == EBADF); } |