OpenProcess success does not prove a process is running: Windows keeps a terminated process object openable while any handle remains. Probe with SYNCHRONIZE and a zero-timeout wait instead. This corrects the production Dolt-server probe and the matching existing Linear helper. The Linear helper has no production caller today; its change is latent correctness and regression coverage, not a current Linear runtime fix. The wait-based design and regression strategy build on Marco Del Pin's contributor work in #4808. Co-authored-by: Marco Del Pin <marco.delpin@gmail.com> Agent-Signature: codex-tui-gpt-5.6-sol-ultra on behalf of Ewen Cuthiell
18 lines
380 B
Go
18 lines
380 B
Go
//go:build windows
|
|
|
|
package linear
|
|
|
|
import (
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func isProcessAlive(pid int) bool {
|
|
h, err := windows.OpenProcess(windows.SYNCHRONIZE, false, uint32(pid))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
defer func() { _ = windows.CloseHandle(h) }()
|
|
|
|
status, err := windows.WaitForSingleObject(h, 0)
|
|
return err == nil && status == uint32(windows.WAIT_TIMEOUT)
|
|
}
|