9647711921
On some systems (namely Windows), syscall.Rlimit is not defined, and
makes the build fail.
This fixes the build by making the rlimit calls only run on archs where
it is defined, defaulting to a stub on other systems.
See: 8427429c59
22 lines
580 B
Go
22 lines
580 B
Go
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
)
|
|
|
|
func bumpOpenedFileLimit() error {
|
|
var rlimit syscall.Rlimit
|
|
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
|
|
return fmt.Errorf("failed to get RLIMIT_NOFILE: %v", err)
|
|
}
|
|
rlimit.Cur = rlimit.Max
|
|
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit); err != nil {
|
|
return fmt.Errorf("failed to set RLIMIT_NOFILE: %v", err)
|
|
}
|
|
return nil
|
|
}
|