go-proc

Pure-Go process-lifecycle primitives — reap, supervise, respawn. No cgo.

pure Go · zero cgo PID-1 subreaper SIGCHLD · Wait4 process supervisor pluggable runtime restart policies grace debounce sliding-window anti-thrash exponential backoff 100% coverage 6 arches
Documentation supervisor respawn
Documentation (MkDocs Material + mike) License: BSD-3-Clause Go 1.26.4+ Coverage 100%

go-proc is a set of pure-Go (no cgo) primitives for supervising the lifecycle of processes — the small, reusable pieces an init or a workload manager needs. Two libraries: supervisor pairs a PID-1 subreaper (SIGCHLD + Wait4) with a process supervisor that drives a pluggable Runtime and restarts children per policy; respawn is a restart/reconcile state machine with grace-period debounce, sliding-window anti-thrash, and backoff. Both were extracted from a microVM init and generalized to depend on no particular workload model — CGO_ENABLED=0, 100% coverage, CI green across 6 arches.

supervisor · subreaper ready

A PID-1 subreaper — signal.Notify(SIGCHLD) + non-blocking Wait4(-1, WNOHANG) — reaps every orphaned child the kernel reparents to the process, publishing a portable Reaped{PID, ExitStatus, Signaled, Signal} per collection. Linux-specific, behind a build tag, with a no-op stub so cross-platform builds stay green.

supervisor · process supervision ready

Drives a pluggable Runtime (an OCI runtime, a fork+exec launcher, a fake) over a Spec of Procs: start each one, correlate reaper exits back to the owning process, and restart per RestartPolicyNever / OnFailure / Always. Stop does SIGTERM → grace → SIGKILL.

respawn · state machine ready

A restart/reconcile machine fed down / up / unhealthy / healthy signals per named unit. Its heart is a pure Decide(policy, history, attempt, signal, now) → Plan function you can assert against a fixed clock; a concurrent per-unit Reconciler is the thin shell around it.

respawn · anti-flap & anti-thrash ready

A grace_period debounces transient flaps before reacting; max_restarts within a sliding window caps thrash and moves a hot unit to cooldown; constant or exponential backoff (capped at 5 min) paces each retry. An unhealthy liveness failure is recovered as stop-then-start.

Pure Go · zero cgo · 6 arches ready

Both libraries are CGO_ENABLED=0, dependency-free, race-tested, gofmt + go vet clean, and green across the six 64-bit Go targets — amd64, arm64, riscv64, loong64, ppc64le, s390x — at 100% test coverage, error branches included.

Generic seams ready

No weft, no gRPC, no health-checker imports: a six-method Runtime interface, a two-method Actions interface, and local value types (RespawnPolicy, SignalKind) are the only coupling points — drop these into any init, agent, or workload manager.

Pure Go with cgo disabled, so it cross-compiles and embeds anywhere — the Linux-only subreaper sits behind a build tag with a portable no-op stub, keeping go build / go vet green on every OS. No dependency on any workload schema, gRPC, or health checker: a Runtime interface, an Actions interface, and local value types are the only seams. Scheduling is a pure function of (policy, history, signal, now), so every decision is testable against a fixed clock. Part of github.com/go-proc.