pstree: Index | Files

package pstree

import ""

Package pstree defines processes and process trees, with the ability to populate them


Package Files


type Process Uses

type Process struct {
    // contains filtered or unexported fields

A Process knows itself, its parent, and who its children are.

func (*Process) ReadProcessInfo Uses

func (proc *Process) ReadProcessInfo(pid ProcessID) (err error)

ReadProcessInfo parses the /proc/pid/stat file to fill the struct. /proc/pid/stat does not contain information about children -- only parents. Linking children to parents is done in a later pass when we know about every process.

type ProcessID Uses

type ProcessID string

ProcessIDs are strings. We don't do math and creation/consumption are guarded with digit globs and digit regexes.

type ProcessTree Uses

type ProcessTree map[ProcessID]*Process

ProcessTree represents every process on a system.

func (ProcessTree) Populate Uses

func (processes ProcessTree) Populate() error

Populate reads the entries in /proc and then assembles the list of children. In order to link parents to children, we must first know every processes's parent.

func (ProcessTree) PrintDepthFirst Uses

func (pids ProcessTree) PrintDepthFirst(pid ProcessID, depth int) string

PrintDepthFirst traverses the hash and recursively prints a parent's children.

func (ProcessTree) String Uses

func (pids ProcessTree) String() string

String assumes the user wants all processes and is a print-friendly wrapper of PrintDepthFirst

Package pstree imports 5 packages (graph). Updated 2016-07-21. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).