| 1 | //go:build windows |
| 2 | |
| 3 | package repair |
| 4 | |
| 5 | import "golang.org/x/sys/windows" |
| 6 | |
| 7 | const stillActiveExitCode = 259 |
| 8 | |
| 9 | func startupProcessAlive(pid int) bool { |
| 10 | if pid <= 0 { |
| 11 | return false |
| 12 | } |
| 13 | handle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) |
| 14 | if err != nil { |
| 15 | return false |
| 16 | } |
| 17 | defer windows.CloseHandle(handle) |
| 18 | var code uint32 |
| 19 | if err := windows.GetExitCodeProcess(handle, &code); err != nil { |
| 20 | return false |
| 21 | } |
| 22 | return code == stillActiveExitCode |
| 23 | } |
| 24 |