From 87e6718233f21b410064d4209fd7bef0befa4865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 1 Nov 2017 13:02:53 +0100 Subject: [PATCH] POSIX: have sysconf(_SC_OPEN_MAX) return the rlimit value. * we use this value in posix_spawn_file_actions_adddup2() for instance, ninja then fails with "Bad file descriptor". --- src/system/libroot/posix/unistd/conf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/libroot/posix/unistd/conf.cpp b/src/system/libroot/posix/unistd/conf.cpp index 8b40bd9f0b..b05dab5364 100644 --- a/src/system/libroot/posix/unistd/conf.cpp +++ b/src/system/libroot/posix/unistd/conf.cpp @@ -37,7 +37,7 @@ getdtablesize(void) { struct rlimit rlimit; if (getrlimit(RLIMIT_NOFILE, &rlimit) < 0) - return 0; + return OPEN_MAX; return rlimit.rlim_cur; } @@ -74,7 +74,7 @@ __sysconf(int name) case _SC_NGROUPS_MAX: return NGROUPS_MAX; case _SC_OPEN_MAX: - return OPEN_MAX; + return getdtablesize(); case _SC_SAVED_IDS: return 1; case _SC_STREAM_MAX: