Documentation
¶
Overview ¶
Package procstate reads process state from a procfs.
It exists as its own package so that the callers which need it are not obliged to make raw path-based reads inside packages whose own reads are held to directory-bound primitives.
The root is a parameter, so what gets read is the caller's choice and this package makes no claim about it. The production caller supplies a kernel filesystem; the reads here are not bound against an operator-writable tree and must not be pointed at one.
The package carries no build constraint, so that a platform without a procfs can still build and import it. There the read fails and the state is reported unavailable, which is what callers must handle in any case.
Index ¶
Constants ¶
const ( Zombie = 'Z' Dead = 'X' DeadLegacy = 'x' )
The procfs state letters treated as meaning the process has exited. Field 3 of proc_pid_stat(5) defines Z for a process awaiting collection by its parent and X for one that is dead; older kernels spelled the latter lowercase x, which is accepted here because accepting it costs nothing.
Every other letter, including one this package does not recognize, is treated as not exited. That is the conservative direction: it can delay noticing that a process has finished, but it cannot declare a live one dead. T and t in particular are stopped rather than finished.
Variables ¶
This section is empty.
Functions ¶
func IsTerminal ¶
IsTerminal reports whether state is one of the procfs letters that mean the process has exited. Every other letter is not terminal.
Types ¶
This section is empty.