kubo/cmd/ipfs/util/ulimit_unix.go
Adin Schmahmann 1f37a1481b go fmt
2022-05-03 14:09:38 -04:00

29 lines
558 B
Go

//go:build darwin || linux || netbsd || openbsd
// +build darwin linux netbsd openbsd
package util
import (
unix "golang.org/x/sys/unix"
)
func init() {
supportsFDManagement = true
getLimit = unixGetLimit
setLimit = unixSetLimit
}
func unixGetLimit() (uint64, uint64, error) {
rlimit := unix.Rlimit{}
err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit)
return rlimit.Cur, rlimit.Max, err
}
func unixSetLimit(soft uint64, max uint64) error {
rlimit := unix.Rlimit{
Cur: soft,
Max: max,
}
return unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit)
}