Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around getrlimit syscall error on darwin #286

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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