* lib/getdtablesize.c: Use rlim_cur instead of rlim_max, to match glibc behavior. test-getdtablesize and test-dup2 both assume they will be able to create a file descriptor numbered (getdtablesize()-1), and will fail if rlim_max > rlim_cur. --- ChangeLog | 6 ++++++ lib/getdtablesize.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog index be46fe9c1388..084338489148 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,12 @@ * doc/posix-headers/monetary.texi: Add Android to the list of platforms missing monetary.h. + getdtablesize: Fix RLIMIT_NOFILE fallback case + * lib/getdtablesize.c: Use rlim_cur instead of rlim_max, to match + glibc behavior. test-getdtablesize and test-dup2 both assume + they will be able to create a file descriptor numbered + (getdtablesize()-1), and will fail if rlim_max > rlim_cur. + 2015-02-08 Daiki Ueno <u...@gnu.org> uniname/unimame-tests: don't link with -lunistring diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c index 59b97360bc57..e23c67d487f8 100644 --- a/lib/getdtablesize.c +++ b/lib/getdtablesize.c @@ -99,8 +99,8 @@ rpl_getdtablesize(void) a smaller soft limit, the smaller limit is not enforced, so we might as well just report the hard limit. */ struct rlimit lim; - if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_max != RLIM_INFINITY) - return lim.rlim_max; + if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_cur != RLIM_INFINITY) + return lim.rlim_cur; return getdtablesize (); } -- 2.2.0.rc0.207.ga3a616c