procinfo

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

View Source
const MaxCmdLen = 4096

MaxCmdLen caps the cmdline string length.

View Source
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

func GetByPIDs(ctx context.Context, pids []int) ([]ProcInfo, error)

GetByPIDs returns process info for the given PIDs. Missing PIDs are silently skipped.

func GetSession

func GetSession(ctx context.Context) ([]ProcInfo, error)

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).

func ListAll

func ListAll(ctx context.Context) ([]ProcInfo, error)

ListAll returns all running processes.

Jump to

Keyboard shortcuts

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