diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go index 0ecb5191..7d31402c 100644 --- a/unix/syscall_unix_test.go +++ b/unix/syscall_unix_test.go @@ -377,11 +377,11 @@ func TestRlimit(t *testing.T) { } set := rlimit set.Cur = set.Max - 1 - if runtime.GOOS == "darwin" && set.Cur > 10240 { - // The max file limit is 10240, even though - // the max returned by Getrlimit is 1<<63-1. - // This is OPEN_MAX in sys/syslimits.h. - set.Cur = 10240 + if runtime.GOOS == "darwin" && set.Cur > 4096 { + // rlim_min for RLIMIT_NOFILE should be equal to + // or lower than kern.maxfilesperproc, which on + // some machines are 4096. See #40564. + set.Cur = 4096 } err = unix.Setrlimit(unix.RLIMIT_NOFILE, &set) if err != nil { @@ -394,6 +394,9 @@ func TestRlimit(t *testing.T) { } set = rlimit set.Cur = set.Max - 1 + if runtime.GOOS == "darwin" && set.Cur > 4096 { + set.Cur = 4096 + } if set != get { // Seems like Darwin requires some privilege to // increase the soft limit of rlimit sandbox, though