kubo/cmd/ipfs/util/ulimit_unix.go
Steven Allen 85acad9a01 gx update go-log, sys, go-crypto
* go-log
* sys
* go-crypto

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-06-08 22:36:24 -07:00

28 lines
578 B
Go

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