2021-12-21 19:32:40 +00:00
|
|
|
|
|
|
|
//go:build openbsd
|
|
|
|
|
|
|
|
|
2021-12-25 08:55:33 +00:00
|
|
|
package common
|
2021-12-21 19:32:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
import "syscall"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-11 17:42:39 +00:00
|
|
|
func SysSetrlimitMemory (_limitMemory uint) (error) {
|
2021-12-21 19:32:40 +00:00
|
|
|
{
|
|
|
|
_limitMb := _limitMemory
|
|
|
|
_limit := syscall.Rlimit {
|
|
|
|
Cur : uint64 (_limitMb) * 1024 * 1024,
|
|
|
|
Max : uint64 (_limitMb) * 1024 * 1024,
|
|
|
|
}
|
|
|
|
if _error := syscall.Setrlimit (syscall.RLIMIT_DATA, &_limit); _error != nil {
|
|
|
|
return _error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-09-11 17:42:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func SysSetrlimitDescriptors (_limitDescriptors uint) (error) {
|
|
|
|
{
|
|
|
|
_limit := syscall.Rlimit {
|
|
|
|
Cur : uint64 (_limitDescriptors),
|
|
|
|
Max : uint64 (_limitDescriptors),
|
|
|
|
}
|
|
|
|
if _error := syscall.Setrlimit (syscall.RLIMIT_NOFILE, &_limit); _error != nil {
|
|
|
|
return _error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|