Documentation
¶
Overview ¶
Package procreg is the saved worker registry (ADR-0167): the process driver and the dev catalog engine record every process they start, so the next open reaps what a crashed run left behind. An entry is reaped only when the live pid's start time and boot match it (ADR-0187), so a reused pid is never signalled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Alive ¶ added in v0.7.0
Alive reports whether e's process is ours and still runs: a zombie counts as gone.
func BootID ¶ added in v0.7.0
BootID reads the boot ID an owner records next to the start time: Linux boot_id, read once; "" on macOS.
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
PID int `json:"pid"`
PGID int `json:"pgid"`
StartTime uint64 `json:"startTime"` // OS-native: clock ticks since boot (Linux), µs since epoch (macOS)
BootID string `json:"bootID,omitempty"` // Linux boot_id at save; "" on macOS and in entries of earlier releases
Token string `json:"token"` // still in argv; checked only for a Linux entry without BootID
Files []string `json:"files"` // driver-owned temp files deleted at reap
}
Entry is one process a registry owner started.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the saved set of entries in <dir>/<name>.json, owned by one process through the lock on <dir>/<name>.lock. It has no mutex of its own: the caller serializes Put, Delete and Close.
func Open ¶
Open takes the registry at <dir>/<name>.json, creating dir, and loads its entries. It fails with fault.Conflict while another owner holds the lock.
func (*Registry) Close ¶
Close empties the registry and releases the lock; a second Close does nothing.
func (*Registry) Reap ¶
Reap ends every saved process that is still ours: SIGTERM to each owned process group, up to grace for all of them together, then SIGKILL to the ones still owned. A group whose leader exits, or is a zombie, gets SIGKILL at once, as a worker's exit does (ADR-0011 C4): its other members outlive the leader, and its pgid is not reused while one lives. It deletes every entry's files, owned or not, and empties the registry. killed counts the process groups it signalled.