bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] getdtablesize: Extend RLIMIT_NOFILE fallback case to Android


From: Kevin Cernekee
Subject: [PATCH 2/3] getdtablesize: Extend RLIMIT_NOFILE fallback case to Android
Date: Sun, 15 Feb 2015 16:49:06 -0800

* 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 | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 5fbd970..9b84dac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -57,6 +57,12 @@
        * doc/posix-headers/monetary.texi: Add Android to the list of
        platforms missing monetary.h.
 
+       getdtablesize: Extend RLIMIT_NOFILE fallback case to Android
+       * 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-11  Pádraig Brady  <address@hidden>
 
        tests: avoid recent -Werror=unused-variable regression in test-locale
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index 59b9736..37caa93 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -92,15 +92,22 @@ getdtablesize (void)
 int
 rpl_getdtablesize(void)
 {
+  struct rlimit lim;
+
+#ifdef __CYGWIN__
   /* To date, this replacement is only compiled for Cygwin 1.7.25,
      which auto-increased the RLIMIT_NOFILE soft limit until it
      hits the compile-time constant hard limit of 3200.  Although
      that version of cygwin supported a child process inheriting
      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;
+#else
+  if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_cur != RLIM_INFINITY)
+    return lim.rlim_cur;
+#endif
+
   return getdtablesize ();
 }
 
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]