procs

package
v0.0.0-...-9759625 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package procs implements process-table helpers (filter, sort) and process actions (terminate, force kill).

Index

Constants

This section is empty.

Variables

View Source
var Signals = []Signal{
	{"TERM", "terminate"},
	{"KILL", "force kill"},
	{"INT", "interrupt"},
	{"HUP", "hangup"},
	{"QUIT", "quit + core"},
	{"STOP", "pause"},
	{"CONT", "resume"},
}

Signals lists the signals offered by the picker, in order. TERM and KILL mirror the classic terminate/force-kill shortcuts. On windows every entry except TERM and KILL is unavailable and the picker hides it.

Functions

func Filter

func Filter(procs []collector.Proc, needle string) []collector.Proc

Filter keeps processes whose name or user contains needle (case-insensitive) or, when needle is all digits, whose PID starts with it.

func ForceKill

func ForceKill(pid int32) error

ForceKill sends SIGKILL on unix; TerminateProcess on windows.

func Kill

func Kill(pid int32) error

Kill sends SIGTERM on unix; TerminateProcess on windows.

func SendSignal

func SendSignal(pid int32, name string) error

SendSignal delivers the named signal to pid. TERM/KILL work on every platform (TerminateProcess on windows); the rest are unix-only.

func SignalIndex

func SignalIndex(name string) int

SignalIndex returns the position of name in Signals, or -1.

func Sort

func Sort(procs []collector.Proc, key SortKey, desc bool)

Sort orders processes in place.

Types

type Signal

type Signal struct {
	Name string // TERM, KILL, INT, …
	Desc string // short label for the picker
}

Signal is a signal wrongtop can deliver to a process.

func AvailableSignals

func AvailableSignals() []Signal

AvailableSignals returns the signals this platform can deliver, in picker order.

type SortKey

type SortKey int

SortKey selects the process table ordering.

const (
	SortCPU SortKey = iota
	SortMem
	SortPID
	SortName
	SortUser
)

Sort keys in cycle order.

func (SortKey) Less

func (k SortKey) Less(a, b collector.Proc) int

Less is the comparison a SortKey induces on processes.

func (SortKey) Next

func (k SortKey) Next() SortKey

Next cycles to the following sort key.

func (SortKey) String

func (k SortKey) String() string

String returns the display name of a sort key.

type TreeNode

type TreeNode struct {
	Proc     collector.Proc
	Depth    int
	Children bool
}

TreeNode is one row of the flattened process forest: a process with its ancestry depth and whether it has children in the current set.

func BuildTree

func BuildTree(procs []collector.Proc, key SortKey, desc bool, collapsed map[int32]bool) []TreeNode

BuildTree orders processes depth-first by parentage for the tree view. Siblings (and parentless roots) sort with key/desc; processes whose parent is not in the set become roots; cycles — possible through PID reuse — are cut by emitting unvisited processes afterwards. Descendants of PIDs in collapsed are hidden.

Jump to

Keyboard shortcuts

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