soju/cmd/soju/rlimit.go
2023-02-23 10:33:48 +01:00

21 lines
512 B
Go

//go: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
}