Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9afe8a3

Browse files
committed
Fix computation of max_fd on OpenBSD. Issue #23852.
2 parents 32d34bc + f968177 commit 9afe8a3

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Modules/_posixsubprocess.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#ifdef HAVE_SYS_SYSCALL_H
1515
#include <sys/syscall.h>
1616
#endif
17+
#if defined(HAVE_SYS_RESOURCE_H)
18+
#include <sys/resource.h>
19+
#endif
1720
#ifdef HAVE_DIRENT_H
1821
#include <dirent.h>
1922
#endif
@@ -174,6 +177,13 @@ safe_get_max_fd(void)
174177
if (local_max_fd >= 0)
175178
return local_max_fd;
176179
#endif
180+
#if defined(HAVE_SYS_RESOURCE_H) && defined(__OpenBSD__)
181+
struct rlimit rl;
182+
/* Not on the POSIX async signal safe functions list but likely
183+
* safe. TODO - Someone should audit OpenBSD to make sure. */
184+
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0)
185+
return (long) rl.rlim_max;
186+
#endif
177187
#ifdef _SC_OPEN_MAX
178188
local_max_fd = sysconf(_SC_OPEN_MAX);
179189
if (local_max_fd == -1)

0 commit comments

Comments
 (0)