From e6cffc1f127be12c0ead4b359bc9ff96aeaecbaa Mon Sep 17 00:00:00 2001 From: HD Moore Date: Tue, 13 Aug 2024 13:21:51 -0500 Subject: [PATCH] freebsd fix --- cmd/os_freebsd.go | 25 +++++++++++++++++++++++++ cmd/os_other.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 cmd/os_freebsd.go diff --git a/cmd/os_freebsd.go b/cmd/os_freebsd.go new file mode 100644 index 0000000..7879811 --- /dev/null +++ b/cmd/os_freebsd.go @@ -0,0 +1,25 @@ +//go:build freebsd + +package cmd + +import "syscall" + +// increaseFileLimit tries to increase our available file limits to the maximum possible +func increaseFileLimit() { + var rLimit syscall.Rlimit + err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) + if err != nil { + return + } + + limits := []int{999999, 99999, 49999, 32766, 9999, 4999, 2048} + + for _, l := range limits { + rLimit.Max = int64(l) + rLimit.Cur = int64(l) + err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) + if err == nil { + return + } + } +} diff --git a/cmd/os_other.go b/cmd/os_other.go index 3baaa66..f666e91 100644 --- a/cmd/os_other.go +++ b/cmd/os_other.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build !windows,!freebsd package cmd