procgroup

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Process group verification

日本語

procgroup owns process identity, scoped snapshots, group inspection, and termination on Linux and macOS. It does not depend on daemon run state, configuration, execution-user resolution, or control-socket peer authentication.

  • Snapshot retains the recorded leader PID and all processes in its group.
  • Inspect verifies kernel birth identities, user, leader command, and previously observed members. Missing leaders and zombie-only snapshots are not by themselves evidence that a group stopped.
  • Stop persists verified members through its single callback before signaling, sends TERM, polls during the grace period, then uses KILL if still necessary. Cancellation and inspection or persistence errors stop the operation.

The caller projects lifecycle state into Group: AllowUnlaunched permits an absent identity only before launch; Done records completed execution. Command is the expected leader command substring. The caller must save members received by the Stop callback durably before returning success.

ProcessIdentity keeps the existing pid, pgid, uid, and started JSON fields so persisted recovery records retain their format.

Documentation

Overview

Package procgroup verifies and terminates process groups using kernel identities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessStart

func ProcessStart(pid int) (string, error)

ProcessStart returns the process birth time scoped to the current kernel boot.

func SameProcess

func SameProcess(a, b ProcessIdentity) bool

SameProcess compares complete process identities, never accepting an empty start.

func Snapshot

func Snapshot(ctx context.Context, identities []ProcessIdentity) (map[int]Entry, error)

Snapshot observes recorded PIDs and every member of their recorded groups.

func Stop

func Stop(ctx context.Context, state Group, persist func([]ProcessIdentity) error) error

Stop sends TERM, polls through a grace period, then sends KILL if needed. persist must durably record verified members before returning nil; it is called before the first signal and whenever inspection discovers changed membership.

func StopWithSignal added in v0.2.0

func StopWithSignal(ctx context.Context, state Group, persist func([]ProcessIdentity) error, signal func(Group, syscall.Signal) error) error

StopWithSignal preserves Stop's identity and persistence checks while delegating signals to a caller authorized to act as the execution user.

Types

type Entry

type Entry struct {
	ProcessIdentity
	Command string
	Zombie  bool
	Exiting bool
}

Entry is one observed process, including status needed to verify group lifetime.

type Group

type Group struct {
	Process         ProcessIdentity
	Members         []ProcessIdentity
	UID             int
	Command         string
	AllowUnlaunched bool
	Done            bool
}

Group contains only the recorded facts needed to authorize inspection and signaling. Command is the expected leader command substring; callers decide which unlaunched lifecycle states are safe through AllowUnlaunched.

type ProcessIdentity

type ProcessIdentity struct {
	PID     int    `json:"pid"`
	PGID    int    `json:"pgid"`
	UID     int    `json:"uid"`
	Started string `json:"started"`
}

ProcessIdentity binds a PID and group to its execution user and kernel birth identity.

func Inspect

func Inspect(state Group, table map[int]Entry) (bool, []ProcessIdentity, error)

Inspect never treats an absent leader as proof that its children exited.

func LaunchedIdentity

func LaunchedIdentity(table map[int]Entry, pid, uid int) (ProcessIdentity, error)

LaunchedIdentity verifies a newly launched leader before its execution gate opens.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL