feat(v0.6): tri-state PID liveness probe (ProcessAlive/Dead/Unknown)

This commit is contained in:
2026-05-15 14:25:31 -04:00
parent 8d5243dce2
commit 9070c4274c
4 changed files with 125 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
package session
// ProcessState is the tri-state result of a PID liveness check. The call
// site decides how to treat ProcessUnknown; IsStale treats it
// conservatively by falling back to wall-clock freshness.
type ProcessState int
const (
// ProcessAlive: the OS confirms a process with this PID exists.
ProcessAlive ProcessState = iota
// ProcessDead: the OS confirms no process with this PID exists.
ProcessDead
// ProcessUnknown: the liveness check was inconclusive (permission
// error, unexpected OS error). Callers must NOT treat this as dead.
ProcessUnknown
)
// checkProcess is the test seam for PID liveness. Production code uses the
// platform-specific defaultCheckProcess. Tests override this package-level
// variable; such tests must restore it via t.Cleanup and must NOT run with
// t.Parallel().
var checkProcess = defaultCheckProcess