2023-03-28 19:39:22 +01:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 09:12:13 -04:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 19:39:22 +01:00
|
|
|
|
2021-11-16 12:04:01 -06:00
|
|
|
//go:build !windows
|
2020-04-02 09:22:17 +02: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 13:35:28 -04:00
|
|
|
// nolint:unconvert // Rlimit.Cur may not be uint64 on all platforms
|
2020-04-02 09:22:17 +02:00
|
|
|
return uint64(limit.Cur), err
|
|
|
|
}
|