//go:build windows package store import ( "golang.org/x/sys/windows" ) // processAlive returns true when the given PID is currently held by a // running Windows process. OpenProcess with PROCESS_QUERY_LIMITED_INFORMATION // is the supported way to check liveness without elevation. func processAlive(pid int) bool { if pid <= 0 { return false } h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) if err != nil { return false } defer windows.CloseHandle(h) var exitCode uint32 if err := windows.GetExitCodeProcess(h, &exitCode); err != nil { // Conservative: if we can't ask, assume alive so we don't reclaim // an active lock. Worst case the operator sees ErrLockHeld and // removes the lockfile by hand. return true } const stillActive = 259 // STILL_ACTIVE return exitCode == stillActive }