[Python-checkins] cpython (merge 3.4 -> default): Fix computation of max_fd on OpenBSD. Issue #23852.

gregory.p.smith python-checkins at python.org
Sun Apr 26 08:44:18 CEST 2015


https://hg.python.org/cpython/rev/08d0cc23fb00
changeset: 95805:08d0cc23fb00
parent: 95803:8c044904cddb
parent: 95804:7df280b311d0
user: Gregory P. Smith <greg at krypto.org>
date: Sat Apr 25 23:44:02 2015 -0700
summary:
 Fix computation of max_fd on OpenBSD. Issue #23852.
files:
 Modules/_posixsubprocess.c | 10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -14,6 +14,9 @@
 #ifdef HAVE_SYS_SYSCALL_H
 #include <sys/syscall.h>
 #endif
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
 #ifdef HAVE_DIRENT_H
 #include <dirent.h>
 #endif
@@ -174,6 +177,13 @@
 if (local_max_fd >= 0)
 return local_max_fd;
 #endif
+#if defined(HAVE_SYS_RESOURCE_H) && defined(__OpenBSD__)
+ struct rlimit rl;
+ /* Not on the POSIX async signal safe functions list but likely
+ * safe. TODO - Someone should audit OpenBSD to make sure. */
+ if (getrlimit(RLIMIT_NOFILE, &rl) >= 0)
+ return (long) rl.rlim_max;
+#endif
 #ifdef _SC_OPEN_MAX
 local_max_fd = sysconf(_SC_OPEN_MAX);
 if (local_max_fd == -1)
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /