1 Star 0 Fork 0

TGodfather / misc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rlimit_unix.go 663 Bytes
一键复制 编辑 原始数据 按行查看 历史
TGodfather 提交于 2023-03-26 10:51 . command on windows
// +build !windows
package system
import (
"syscall"
)
func SetLimit(limitSetting uint64, force bool ){
var limit syscall.Rlimit
syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit)
//如果强制设置,不管系统原来的值
if force {
limit.Cur = limitSetting
}else {
// 如果系统值比设置高,则使用系统值
if limit.Cur < limitSetting{
limit.Cur = limitSetting
if limit.Max < limitSetting{
limit.Max = limitSetting
}
}
}
syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit)
}
func GetLimit() (uint64, uint64) {
var limit syscall.Rlimit
syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit)
return limit.Max, limit.Cur
}
Go
1
https://gitee.com/tgodfather/misc.git
git@gitee.com:tgodfather/misc.git
tgodfather
misc
misc
4dc1fac3246d

搜索帮助

53164aa7 5694891 3bd8fe86 5694891