2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 18:39:22 +00:00
|
|
|
|
2021-11-16 18:04:01 +00:00
|
|
|
//go:build !windows
|
2020-04-02 07:22:17 +00:00
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
|
|
|
|
// getrlimit return the max file descriptors allocated by system
|
|
|
|
// return the number of file descriptors max
|
|
|
|
func getrlimit() (uint64, error) {
|
|
|
|
var limit unix.Rlimit
|
|
|
|
err := unix.Getrlimit(unix.RLIMIT_NOFILE, &limit)
|
2020-04-16 17:35:28 +00:00
|
|
|
// nolint:unconvert // Rlimit.Cur may not be uint64 on all platforms
|
2020-04-02 07:22:17 +00:00
|
|
|
return uint64(limit.Cur), err
|
|
|
|
}
|