1//go:build windows
 2
 3package watcher
 4
 5import (
 6	"syscall"
 7	"unsafe"
 8
 9	"golang.org/x/sys/windows"
10)
11
12var (
13	kernel32                  = windows.NewLazyDLL("kernel32.dll")
14	procGetProcessHandleCount = kernel32.NewProc("GetProcessHandleCount")
15)
16
17func Ulimit() (uint64, error) {
18	// Windows doesn't have the same file descriptor limits as Unix systems
19	// Instead, we can get the current handle count for monitoring purposes
20	currentProcess := windows.CurrentProcess()
21
22	var handleCount uint32
23	ret, _, err := procGetProcessHandleCount.Call(
24		uintptr(currentProcess),
25		uintptr(unsafe.Pointer(&handleCount)),
26	)
27
28	if ret == 0 {
29		// If the call failed, return a reasonable default
30		if err != syscall.Errno(0) {
31			return 2048, nil
32		}
33	}
34
35	// Windows typically allows much higher handle counts than Unix file descriptors
36	// Return the current count, which serves as a baseline for monitoring
37	return uint64(handleCount), nil
38}