Documentation
¶
Overview ¶
Package procinfo provides OS-specific process information for the ps builtin.
This package is in builtins/internal/ and is therefore exempt from the builtinAllowedSymbols allowlist check. It may use OS-specific APIs freely.
Index ¶
Constants ¶
const DefaultProcPath = procpath.Default
DefaultProcPath is the default path to the proc filesystem.
const MaxCmdLen = 4096
MaxCmdLen caps the cmdline string length.
const MaxProcesses = 10_000
MaxProcesses caps slice allocation when listing all processes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProcInfo ¶
type ProcInfo struct {
PID int
PPID int
UID string // username or numeric UID string
State string // single char: R, S, D, Z, T, ...
TTY string // "?" if no controlling terminal
CPU int // %CPU (always 0 for simplicity)
STime string // start time (HH:MM or Mon DD)
Time string // cumulative CPU time HH:MM:SS
Cmd string // full cmdline, truncated to MaxCmdLen
}
ProcInfo holds information about a single process.
func GetByPIDs ¶
GetByPIDs returns process info for the given PIDs. Missing PIDs are silently skipped. procPath is the path to the proc filesystem; pass DefaultProcPath or an empty string to use the default.
func GetSession ¶
GetSession returns processes in the current process session (walks PPID chain from os.Getpid() upward to collect ancestors, plus any processes that share the same session ID when available). procPath is the path to the proc filesystem; pass DefaultProcPath or an empty string to use the default.