//go:build windows package cli import "golang.org/x/sys/windows" // processAlive reports whether a process with pid exists. func processAlive(pid int) bool { if pid <= 0 { return false } h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) //nolint:gosec // PIDs fit in uint32. if err != nil { return false } defer windows.CloseHandle(h) //nolint:errcheck var code uint32 if err := windows.GetExitCodeProcess(h, &code); err != nil { return false } const stillActive = 259 return code == stillActive }