Skip to content

Commit 63024de

Browse files
authored
fix(daemon): cast rlim.Cur to uint64 for freebsd build (#585)
1 parent a7219fd commit 63024de

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/daemon/fd_limit_unix.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ import "syscall"
1212
// Unix-only because syscall.Getrlimit / syscall.Rlimit / syscall.RLIMIT_NOFILE
1313
// are guarded by `//go:build unix` upstream and don't exist for GOOS=windows.
1414
// See fd_limit_windows.go for the Windows stub.
15+
//
16+
// rlim.Cur is uint64 on linux and darwin but int64 on freebsd; cast to keep
17+
// the cross-GOOS return type stable. Negative values can't occur for
18+
// RLIMIT_NOFILE in practice.
1519
func CurrentProcessFDLimit() uint64 {
1620
var rlim syscall.Rlimit
1721
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil {
1822
return 0
1923
}
20-
return rlim.Cur
24+
return uint64(rlim.Cur)
2125
}

0 commit comments

Comments
 (0)