From: Gregory P. Smith Date: Sun, 26 Apr 2015 06:43:34 +0000 (-0700) Subject: Fix computation of max_fd on OpenBSD. Issue #23852. X-Git-Tag: v3.5.0b1~286^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f9681776c97757540200b6a0261c89c57c94f580;p=thirdparty%2FPython%2Fcpython.git Fix computation of max_fd on OpenBSD. Issue #23852. --- diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index f0a272e118f4..452d592f1504 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -14,6 +14,9 @@ #ifdef HAVE_SYS_SYSCALL_H #include #endif +#if defined(HAVE_SYS_RESOURCE_H) +#include +#endif #ifdef HAVE_DIRENT_H #include #endif @@ -174,6 +177,13 @@ safe_get_max_fd(void) 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)