proctree

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package proctree inspects process trees across supported platforms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree is a point-in-time view of the process table captured once per scan. Reuse it for every PID in that scan: on platforms without /proc this reads the table in one or two ps calls instead of reforking ps per PID, and every lookup is memoised so repeated queries (e.g. Descendants computed per pane, Environ checked per candidate) never refork.

func Capture

func Capture() *Tree

Capture snapshots the current process table.

func (*Tree) CWD

func (t *Tree) CWD(pid int) string

CWD returns the working directory of the given process with symlinks resolved. Resolved lazily and memoised: only the rare legacy/orphan paths need it, so each PID is looked up at most once (and on platforms without /proc that lookup forks lsof, which the common ID-matched path avoids).

func (*Tree) Cmdline

func (t *Tree) Cmdline(pid int) []string

Cmdline returns the argv of the given process.

func (*Tree) Descendants

func (t *Tree) Descendants(rootPID int) []int

Descendants returns root and all its transitive child PIDs.

func (*Tree) Environ

func (t *Tree) Environ(pid int) map[string]string

Environ returns the environment of the given process.

Jump to

Keyboard shortcuts

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