X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-posix_spawn_file_actions_addclose.c;h=c6790dd398642dc86e8ab8ca8bf5b89dcf0c19cf;hb=1276a2c5f24c0c932426aca9c899fa524d2443f2;hp=ae149246ce10325a1711a8cb7bb73b336d15bbbc;hpb=9fc81090f6c5590bd1b0e0fa5087577a2ee43a3e;p=gnulib.git diff --git a/tests/test-posix_spawn_file_actions_addclose.c b/tests/test-posix_spawn_file_actions_addclose.c index ae149246c..c6790dd39 100644 --- a/tests/test-posix_spawn_file_actions_addclose.c +++ b/tests/test-posix_spawn_file_actions_addclose.c @@ -1,5 +1,5 @@ /* Test posix_spawn_file_actions_addclose() function. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,9 +23,25 @@ SIGNATURE_CHECK (posix_spawn_file_actions_addclose, int, (posix_spawn_file_actions_t *, int)); #include +#include +#include #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) { @@ -39,8 +55,9 @@ main (void) ASSERT (posix_spawn_file_actions_addclose (&actions, -1) == EBADF); } { + int bad_fd = big_fd (); errno = 0; - ASSERT (posix_spawn_file_actions_addclose (&actions, 10000000) == EBADF); + ASSERT (posix_spawn_file_actions_addclose (&actions, bad_fd) == EBADF); } return 0;