Commit f9681776 authored by Gregory P. Smith's avatar Gregory P. Smith

Fix computation of max_fd on OpenBSD. Issue #23852.

parent d87dd434
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
#ifdef HAVE_SYS_SYSCALL_H #ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> #include <sys/syscall.h>
#endif #endif
#if defined(HAVE_SYS_RESOURCE_H)
#include <sys/resource.h>
#endif
#ifdef HAVE_DIRENT_H #ifdef HAVE_DIRENT_H
#include <dirent.h> #include <dirent.h>
#endif #endif
...@@ -174,6 +177,13 @@ safe_get_max_fd(void) ...@@ -174,6 +177,13 @@ safe_get_max_fd(void)
if (local_max_fd >= 0) if (local_max_fd >= 0)
return local_max_fd; return local_max_fd;
#endif #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 #ifdef _SC_OPEN_MAX
local_max_fd = sysconf(_SC_OPEN_MAX); local_max_fd = sysconf(_SC_OPEN_MAX);
if (local_max_fd == -1) if (local_max_fd == -1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment