X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-posix_spawn_file_actions_adddup2.c;h=347e78328773c8554deadfd49cda6dc7b28f1a22;hb=1276a2c5f24c0c932426aca9c899fa524d2443f2;hp=d728eff61c595fe04368e5830f9a13526ba85868;hpb=f8a3550c9b4cea9cccb72d9ba09fce1aebd1a146;p=gnulib.git diff --git a/tests/test-posix_spawn_file_actions_adddup2.c b/tests/test-posix_spawn_file_actions_adddup2.c index d728eff61..347e78328 100644 --- a/tests/test-posix_spawn_file_actions_adddup2.c +++ b/tests/test-posix_spawn_file_actions_adddup2.c @@ -1,5 +1,5 @@ /* Test posix_spawn_file_actions_adddup2() 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,14 +23,29 @@ SIGNATURE_CHECK (posix_spawn_file_actions_adddup2, int, (posix_spawn_file_actions_t *, int, 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) { - int bad_fd = getdtablesize (); + int bad_fd = big_fd (); posix_spawn_file_actions_t actions; ASSERT (posix_spawn_file_actions_init (&actions) == 0);