Source file src/syscall/rlimit_darwin.go
1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build darwin 6 7 package syscall 8 9 // adjustFileLimit adds per-OS limitations on the Rlimit used for RLIMIT_NOFILE. See rlimit.go. 10 func adjustFileLimit(lim *Rlimit) { 11 // On older macOS, setrlimit(RLIMIT_NOFILE, lim) with lim.Cur = infinity fails. 12 // Set to the value of kern.maxfilesperproc instead. 13 n, err := SysctlUint32("kern.maxfilesperproc") 14 if err != nil { 15 return 16 } 17 if lim.Cur > uint64(n) { 18 lim.Cur = uint64(n) 19 } 20 } 21