X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-posix_spawn_file_actions_addopen.c;h=a4865ca97e0258a3f3c946faf34874981131383a;hb=3386f3988ce2ab14d65f59659d8f95bf4830ecb3;hp=600772547d624cf2cc5effe649ee057c545f297f;hpb=73c46e26886dc0e186054134b1ae8d3641d5b89e;p=gnulib.git diff --git a/tests/test-posix_spawn_file_actions_addopen.c b/tests/test-posix_spawn_file_actions_addopen.c index 600772547..a4865ca97 100644 --- a/tests/test-posix_spawn_file_actions_addopen.c +++ b/tests/test-posix_spawn_file_actions_addopen.c @@ -1,5 +1,5 @@ /* Test posix_spawn_file_actions_addopen() function. - Copyright (C) 2011 Free Software Foundation, Inc. + Copyright (C) 2011-2013 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 @@ -25,9 +25,25 @@ SIGNATURE_CHECK (posix_spawn_file_actions_addopen, int, #include #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) { @@ -43,8 +59,9 @@ main (void) == EBADF); } { + int bad_fd = big_fd (); errno = 0; - ASSERT (posix_spawn_file_actions_addopen (&actions, 10000000, + ASSERT (posix_spawn_file_actions_addopen (&actions, bad_fd, "foo", 0, O_RDONLY) == EBADF); }