vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
|
215f8aeb
Keenan Nemetz
2d ago
|
1 | //go:build windows |
| 2 | ||
|
de3eec16
Keenan Nemetz
2h ago
|
3 | package container |
|
215f8aeb
Keenan Nemetz
2d ago
|
4 | |
| 5 | import ( | |
| 6 | "errors" | |
| 7 | ||
| 8 | "golang.org/x/sys/windows" | |
| 9 | ) | |
| 10 | ||
| 11 | // stillActive is GetExitCodeProcess's answer for a process that has not exited. | |
| 12 | // x/sys/windows exposes it under its NT status name and not the Win32 one. | |
| 13 | const stillActive = 259 | |
| 14 | ||
| 15 | // processAlive reports whether a process with this pid still exists. The handle | |
| 16 | // is opened with the least access that can report an exit code; a process this | |
| 17 | // account may not open is treated as alive, because reclaiming a directory a | |
| 18 | // live runner is still using is the failure this check prevents. | |
| 19 | func processAlive(pid int) bool { | |
| 20 | h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) | |
| 21 | if err != nil { | |
| 22 | // A pid that is not running is the one answer that means "gone". | |
| 23 | return !errors.Is(err, windows.ERROR_INVALID_PARAMETER) | |
| 24 | } | |
| 25 | defer windows.CloseHandle(h) | |
| 26 | var code uint32 | |
| 27 | if err := windows.GetExitCodeProcess(h, &code); err != nil { | |
| 28 | return true | |
| 29 | } | |
| 30 | return code == stillActive | |
| 31 | } |