diff --git a/test/fdpass.c b/test/fdpass.c index 0ea7518c..1bcd9cab 100644 --- a/test/fdpass.c +++ b/test/fdpass.c @@ -857,9 +857,22 @@ main (int argc, * for stdout, stderr, duplicates, the D-Bus connection, etc. */ lim.rlim_cur < 2 * MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES) { - g_message ("not enough RLIMIT_NOFILE to run this test"); - /* Autotools exit code for "all skipped" */ - return 77; + if (lim.rlim_max >= 2 * MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES) + { + lim.rlim_cur = 2 * MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES; + if ((lim.rlim_cur < 4 * TOO_MANY_FDS) && + (lim.rlim_max >= 4 * TOO_MANY_FDS)) + lim.rlim_cur = 4 * TOO_MANY_FDS; + if (setrlimit (RLIMIT_NOFILE, &lim) < 0) + g_error ("Failed to set RLIMIT_NOFILE limit to %lu: %s", + (unsigned long) lim.rlim_cur, g_strerror (errno)); + } + else + { + g_message ("not enough RLIMIT_NOFILE to run this test"); + /* Autotools exit code for "all skipped" */ + return 77; + } } } #endif