summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2015-04-26 06:44:02 (GMT)
committerGregory P. Smith <greg@krypto.org>2015-04-26 06:44:02 (GMT)
commit9afe8a330664fa8c301e770cc5123c2902b6a77d (patch)
tree8fe147ea83933a8f2114dcf3eca4ea81210ca627 /Modules
parent32d34bcf1d8b6b409df998ab73bba1e17d5862e9 (diff)
parentf9681776c97757540200b6a0261c89c57c94f580 (diff)
downloadcpython-9afe8a330664fa8c301e770cc5123c2902b6a77d.zip
cpython-9afe8a330664fa8c301e770cc5123c2902b6a77d.tar.gz
cpython-9afe8a330664fa8c301e770cc5123c2902b6a77d.tar.bz2
Fix computation of max_fd on OpenBSD. Issue #23852.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_posixsubprocess.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 00989bc..a327fc5 100644
--- 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 @@ 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)