procinventory

package
v0.2.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package procinventory reads process identities from procfs for the acceptance harnesses, which observe what an installed candidate started before they may repair anything themselves.

Listing processes and reading their per-process files are separate steps, so a process can exit in between: ESRCH and ENOENT both mean "already exited" and count as an absence rather than a failed observation. Only processes still present when an inventory completes are reported, so a caller's ownership assertions apply to survivors alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Descendants

func Descendants(pid int) ([]int, error)

Descendants lists the PIDs procfs reports as children of pid across all of its threads. A thread, or the whole process, that exits while the lists are read contributes nothing instead of failing the listing. The PIDs are the ones procfs reported; any of them may have exited by the time a caller reads them, which Read then reports through Exited.

func Exited

func Exited(err error) bool

Exited reports whether err means the process was already gone when it was read, rather than a failure of the observation itself.

func Live

func Live(p Process) bool

Live reports whether p was still running rather than a zombie or a dead entry awaiting removal.

func Same

func Same(a, b Process) bool

Same reports whether two readings describe the same process rather than a reuse of its PID.

Types

type Process

type Process struct {
	PID        int      `json:"pid"`
	Parent     int      `json:"parent_pid"`
	Group      int      `json:"group"`
	Start      string   `json:"start_ticks"`
	Executable string   `json:"executable"`
	Command    string   `json:"command"`
	Arguments  []string `json:"arguments,omitempty"`
	State      string   `json:"state"`
}

Process is one process as procfs reported it. Start is the start time in clock ticks, which separates a live process from a later reuse of its PID, and State is the single-letter state from stat.

func Inventory

func Inventory(pids []int) ([]Process, error)

Inventory reads every PID in pids and reports, in the order given, the processes still present when it completed; every read failure that does not mean "already exited" is reported. Each identity comes from the confirming read, so a caller holding an earlier one can still recognize a reused PID.

func Read

func Read(pid int) (Process, error)

Read returns the identity of pid as procfs reports it. A process that has already exited yields an error for which Exited reports true. The stat file is read again after the other per-process files, so a PID reused during the read cannot contribute a mixture of two processes' fields.

Jump to

Keyboard shortcuts

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