Skip to content

Commit

Permalink
Work around getrlimit syscall error on darwin (#286)
Browse files Browse the repository at this point in the history
Fixes #285
  • Loading branch information
jeremyschlatter authored and achew22 committed Sep 19, 2019
1 parent e22acf9 commit cc87648
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ibazel/main_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package main

import "syscall"
import (
"runtime"
"syscall"
)

func setUlimit() error {
var lim syscall.Rlimit
Expand All @@ -31,6 +34,15 @@ func setUlimit() error {
// http://man7.org/linux/man-pages/man2/getrlimit.2.html
lim.Cur = lim.Max

// If we're on darwin, work around the fact that Getrlimit reports
// the wrong value. See https://github.com/golang/go/issues/30401
if runtime.GOOS == "darwin" && lim.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.
lim.Cur = 10240
}

err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)
if err != nil {
return err
Expand Down

0 comments on commit cc87648

Please sign in to comment.