tree

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrintOption

type PrintOption func(*Printer) *Printer

func WithColors

func WithColors(colored bool) PrintOption

WithColors returns an option that enables or disables colored output.

func WithContainers

func WithContainers(mgr *containers.Manager) PrintOption

WithContainers returns an option that sets the container manager for container labels.

type Printer

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

Printer handles tree printing with various options.

func NewPrinter

func NewPrinter(pt *ProcessTree, opts ...PrintOption) *Printer

NewPrinter creates a new Printer for the given tree.

func (*Printer) PrintFiltered

func (p *Printer) PrintFiltered(w io.Writer, pidSet map[int32]bool)

PrintFiltered prints only the specified PIDs and their descendants.

func (*Printer) PrintLineages

func (p *Printer) PrintLineages(w io.Writer, pids []int32) error

PrintLineages prints merged lineages of multiple PIDs.

func (*Printer) PrintSubtree

func (p *Printer) PrintSubtree(w io.Writer, pid int32) error

PrintSubtree prints the subtree rooted at the given PID.

func (*Printer) PrintTree

func (p *Printer) PrintTree(w io.Writer)

PrintTree prints the entire process tree.

type ProcessTree

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

ProcessTree represents a tree of processes indexed by PID.

func New

func New() *ProcessTree

New creates a new empty ProcessTree.

func (*ProcessTree) Add

func (pt *ProcessTree) Add(td *unmarshal.TaskDescriptor)

Add inserts a process into the tree.

func (*ProcessTree) All

func (pt *ProcessTree) All() []*unmarshal.TaskDescriptor

All returns all TaskDescriptors in the tree.

func (*ProcessTree) BuildLineageSubtree

func (pt *ProcessTree) BuildLineageSubtree(pids []int32) (*ProcessTree, error)

BuildLineageSubtree creates a new tree containing only nodes in the lineages of the given PIDs.

func (*ProcessTree) Children

func (pt *ProcessTree) Children(pid int32) []int32

Children returns the child PIDs of a given process.

func (*ProcessTree) ChildrenSorted

func (pt *ProcessTree) ChildrenSorted(pid int32) []int32

ChildrenSorted returns the child PIDs sorted numerically.

func (*ProcessTree) FindRoots

func (pt *ProcessTree) FindRoots() []int32

FindRoots returns PIDs of processes that are tree roots. A root is a process whose parent is not in the tree.

func (*ProcessTree) Get

func (pt *ProcessTree) Get(pid int32) *unmarshal.TaskDescriptor

Get returns a process by PID, or nil if not found.

func (*ProcessTree) GetLineage

func (pt *ProcessTree) GetLineage(pid int32) ([]*unmarshal.TaskDescriptor, error)

GetLineage returns the ancestry of a process from root to the given PID.

func (*ProcessTree) Size

func (pt *ProcessTree) Size() int

Size returns the number of processes in the tree.

Jump to

Keyboard shortcuts

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