2021-11-15 19:09:07 +00:00
|
|
|
//go:build !windows
|
2021-11-22 14:09:03 +00:00
|
|
|
// +build !windows
|
2021-03-19 12:37:14 +00:00
|
|
|
|
2022-09-17 19:19:45 +00:00
|
|
|
// Package rlimit contains a function to raise rlimit.
|
2021-03-19 12:37:14 +00:00
|
|
|
package rlimit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Raise raises the number of file descriptors that can be opened.
|
|
|
|
func Raise() error {
|
|
|
|
var rlim syscall.Rlimit
|
|
|
|
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
rlim.Cur = 999999
|
|
|
|
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|