proc

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Process group control and process table queries shared by the shell and the MCP child processes

Index

Constants

View Source
const CwdAvailable = true

Linux reads every process cwd from procfs

Variables

View Source
var ErrAccessDenied = errors.New("access denied")

Raised when the OS refuses to show another process's descriptors, psutil AccessDenied

View Source
var ErrNoSuchProcess = errors.New("no such process")

Error of a probe whose pid does not exist

Functions

func Birth

func Birth(pid int) (float64, error)

Creation epoch of pid like psutil create_time

func BootStart

func BootStart(pid int) (float64, bool)

Seconds between boot and the start of pid, false when unreadable

func BootTime

func BootTime() (float64, error)

Boot epoch in seconds like psutil boot_time, read from /proc/stat btime

func ClockTicks

func ClockTicks() float64

Kernel clock ticks per second, the SC_CLK_TCK psutil divides CPU and start times by

func Cmdline

func Cmdline(pid int) ([]string, error)

Argument vector of pid from /proc/pid/cmdline

func Cwd

func Cwd(pid int) (string, error)

Working directory of pid like psutil, a deleted suffix dropped unless that literal path exists

func Environ

func Environ(pid int) (map[string]string, error)

Environment of pid parsed from /proc/pid/environ

func Exe

func Exe(pid int) (string, error)

Executable path of pid, empty for a live kernel thread without one

func Exists

func Exists(pid int) bool

Reports a live process for pid without signalling it, zombies counting as dead and a pid outside the 32-bit pid_t range naming no process

func Group

func Group(cmd *exec.Cmd)

Puts the command in its own process group so Kill can reach every descendant

func Kill

func Kill(cmd *exec.Cmd) error

Kills the command together with every process in its group

func KillPID

func KillPID(pid int) error

Kills pid outright with SIGKILL or TerminateProcess

func KillTree

func KillTree(pid int)

Kills pid and every descendant, sweeping twice so children forked during the first pass die too

func Name

func Name(pid int) (string, error)

Process name like psutil, a 15 byte kernel name widened to the argv0 basename it truncates

func PIDs

func PIDs() ([]int, error)

Every live pid in ascending order like psutil pids

func PPID

func PPID(pid int) (int, bool)

Parent pid of pid, false when unreadable

func Parents

func Parents(pid int) ([]int, error)

Ancestors of pid nearest first like psutil, ending at the lowest pid, a vanished parent or a reused pid

func PidExists

func PidExists(pid int) (bool, error)

Whether pid names a process as psutil pid_exists answers, zombies counted and the error psutil raises returned

func RSS

func RSS(pid int) (int64, error)

Resident set size of pid in bytes, the statm resident pages times the page size

func RealUID

func RealUID(pid int) (int, error)

Real uid of pid from the Uid line of its status file

func SignalProbeLive

func SignalProbeLive(pid int) bool

Whether a signal zero to pid succeeds or is denied, any other failure reading as dead

func State

func State(pid int) (byte, error)

Status letter of pid with dead folded to X, the source psutil reads its status from

func Terminate

func Terminate(pid int) error

Asks pid to exit with SIGTERM

func Username

func Username(pid int) (string, error)

Account owning pid through its real uid in /proc status

func WorkerBirth

func WorkerBirth(pid int) (float64, error)

Boot relative start of pid, the stamp worker records compare against

func Zombie

func Zombie(pid int) bool

Whether pid exited and waits to be reaped

Types

type OpenFile

type OpenFile struct {
	Path string
	FD   int
}

One regular file a process holds open, as psutil open_files reports it

type Process

type Process struct {
	PID  int
	PPID int
	// Exited but not yet reaped by its parent
	Zombie bool
}

One row of the process table

type Table

type Table []Process

Processes running at one instant

func Snapshot

func Snapshot() (Table, error)

Every process the OS lists at one instant

func (Table) Descendants

func (t Table) Descendants(pid int) []int

Every live descendant of pid, parents before their children, zombies left for their parent to reap

Jump to

Keyboard shortcuts

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