//go:build windows package plugin import "golang.org/x/sys/windows" // living says whether pid is still running. func living(pid int) bool { const stillActive = 259 // STILL_ACTIVE h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) if err != nil { return false } defer windows.CloseHandle(h) var code uint32 if err := windows.GetExitCodeProcess(h, &code); err != nil { return false } return code == stillActive } func endPID(pid int) { if h, err := windows.OpenProcess(windows.PROCESS_TERMINATE, false, uint32(pid)); err == nil { _ = windows.TerminateProcess(h, 1) _ = windows.CloseHandle(h) } }