aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 551f168683..90a0aba460 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2986,6 +2986,14 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
const posix = std.os;
var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried.
+ if (std.Target.current.isDarwin()) {
+ // On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.
+ // According to the man pages for setrlimit():
+ // setrlimit() now returns with errno set to EINVAL in places that historically succeeded.
+ // It no longer accepts "rlim_cur = RLIM_INFINITY" for RLIM_NOFILE.
+ // Use "rlim_cur = min(OPEN_MAX, rlim_max)".
+ lim.max = std.math.min(posix.darwin.OPEN_MAX, lim.max);
+ }
if (lim.cur == lim.max) return;
// Do a binary search for the limit.