proc

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 25 Imported by: ? 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

Child process steps every part of icebath takes the same way: how a child is started and how its end is read

Index

Constants

View Source
const (
	BatteryGood     = "good"
	BatteryWarn     = "warn"
	BatteryBad      = "bad"
	BatteryCritical = "critical"
	BatteryDim      = "dim"
)

Categories of a battery, alpha's, by which the status line colours it

View Source
const (
	NVIDIA   = "nvidia"
	AMD      = "amd"
	Intel    = "intel"
	Apple    = "apple"
	Qualcomm = "qualcomm"
)

Makers of graphics processors, as the PCI ids of their devices name them

Variables

This section is empty.

Functions

func Android

func Android() bool

Whether this process runs on Android, a build for it or a shell of Termux

func CPUFeatures

func CPUFeatures() []string

Vector and matrix instruction sets of this computer's processor that the builds of a program pick a variant of their code by, such as AVX2 or SVE, by the names their makers give them. The base ones every processor of its kind has left out

func Command

func Command(pid int) string

Name of the program the process with the pid runs, as the system keeps it. Empty when it can't be read

func Contained

func Contained() bool

Whether this process runs in a container: a Docker or Podman marker file, a Kubernetes pod, a container runtime in the first process's control group or under the root mount. Looked at once, as where a process runs does not change while it runs

func Environ

func Environ(env map[string]string) []string

Environment as a child takes it, NAME=value entries sorted by name

func ExitCode

func ExitCode(state *os.ProcessState) int

Exit code of a finished process, the negated number of the signal that ended one a signal ended

func Fares

func Fares(pid int, start int64) (runs, told bool)

Whether the process that had the pid when StartTime gave start for it still runs, and whether the system told: it does not while a process this one may not look at has the pid

func Gone

func Gone(pid int) bool

Whether no process with the pid runs, signal zero asking without sending anything: one this process may not signal still runs

func Helper

func Helper(ctx context.Context, names []string, argv ...string) *exec.Cmd

Helper program acting for no profile, such as one that lists processes: started with the variables of Machine alone and the names given, its console window hidden

func HideWindow

func HideWindow(*exec.Cmd)

Keeps a child from opening a console window of its own, which only Windows gives it

func Machine

func Machine(names ...string) map[string]string

Environment of a helper program that acts for no profile and may see none of the user's variables, such as one that lists processes: the variables of this machine and the language settings of this process, and those named besides, each as this process has it

func Main

func Main(program func())

Runs the program, keeping the first thread of the process apart for the processes orphaned below it: the first process of a container reaps them from its start, any other once Adopt made it their reaper. Returns once the program returned

func Managers

func Managers() []string

Package managers of this system whose program is on the search path, the one that installs its programs first: pkg in Termux, Homebrew then MacPorts on macOS, winget, Scoop then Chocolatey on Windows, the distribution's own on Linux by what os-release says of it

func Retitle

func Retitle(t Title)

Names the process by the system's own means for what it is, at start and again whenever that changes: Linux names the first thread of the process, which ps and top read, macOS the thread that asks, and Windows names a process only after its program file. Never fatal. Whether the system took the name is kept for Titled

func Running

func Running(pid int) bool

Whether the process exists, though it may be a zombie

func SameStart

func SameStart(recorded, current int64) bool

Whether two start times name the same incarnation of a process

func Shell

func Shell() string

The plain shell of the system that runs a command line: Termux's on Termux and Android's elsewhere on Android, which keeps no /bin, otherwise /bin/sh. A program of Go starts others by the system call, never through the libc Termux preloads to send /bin/sh to its own

func Standing

func Standing(pid int) (bool, int64, bool)

Whether the process runs and is no zombie, and its start time with whether that could be read, from one read of its stat file where this machine has one

func StartTime

func StartTime(pid int) (int64, bool)

Start time of a process, kernel ticks on Linux else ps's lstart in centiseconds

func Sweep

func Sweep(grace time.Duration) int

Ends the processes left once the program stopped what it owns: the first process of a container every other process in it at once, a subreaper each orphan it took up and each handed to it meanwhile. They are told to end, and to go on if stopped so they hear it, given the grace while what is handed over is reaped as it ends, then killed and given a second more. Answers how many were told to end. None for a process that takes up nothing

func Termux

func Termux() bool

Whether this process runs in Termux, the Linux userland of Android: Termux names its version in TERMUX_VERSION and its folder in PREFIX

func TermuxPrefix

func TermuxPrefix() string

Folder of Termux's programs, libraries and settings, PREFIX in its shells. Empty outside Termux

func Titled

func Titled() (string, bool)

Name the process was last given and whether the system took it. Empty before Retitle

func Unreaped

func Unreaped(parent int) int

How many processes whose parent is the one with the pid ended and wait for it to reap them

func Vendor

func Vendor(id string) string

Maker of a device by its PCI vendor id, as four hex digits with or without 0x. Empty for one of another maker

func Zombie

func Zombie(pid int) bool

Whether the process exited and waits for its parent to reap it

Types

type Battery

type Battery struct {
	// Charge in percent, -1 when not known, as for a computer with none
	Percent int
	// The computer runs on the battery, unplugged from the wall
	Draining bool
	// The computer is plugged into the wall. Neither this nor Draining when the system does not say
	Plugged bool
	// The battery is being charged now
	Charging bool
	// The system saves power, as Windows' battery saver, macOS's Low Power Mode or a low-power platform profile of Linux do
	Saver bool
	// How long the battery lasts at the rate it drains now, as the system reckons it. Zero when it does not say or the battery does not
	// drain
	Left time.Duration
	// Batteries it is made of, some laptops having two. Zero when the system does not say
	Cells int
}

The battery of this computer as the system tells it

func ReadBattery

func ReadBattery() (Battery, bool)

The battery of this computer as read within the last few seconds. false for a computer with none, or whose system does not tell, its charge then -1

func (Battery) Category

func (b Battery) Category() string

Category of the battery, as alpha buckets it for the colour of the status line: dim when its charge is not known, good while it is plugged in, critical at 10 percent or less, bad at 20, warn at 50, good above

type GPU

type GPU struct {
	// One of the makers above, empty when it is not known
	Vendor string
	Name   string
	// Its PCI device id as four lower case hex digits, empty when the system does not say
	Device string
	// Memory of its own in bytes and how much of it is free now, both zero when the system does not say. For one that shares the computer's
	// memory, what of that memory it may use
	Memory, Free int64
	// It works in the computer's memory rather than memory of its own, as an integrated, an Apple silicon or an NVIDIA N1X processor does
	Shared bool
	// Version of its driver, and for an NVIDIA one the newest CUDA its driver runs, such as 13.0; empty when not known
	Driver, CUDA string
	// The driver by name: the kernel's module on Linux, such as amdgpu, or the maker of the driver on Windows. Empty when not known
	Module string
	// Share of the last moment it was busy, in percent, -1 when not known
	Busy int
}

One graphics processor of this computer as its system and driver tell it

func ReadGPUs

func ReadGPUs() []GPU

Graphics processors of this computer, discrete ones first and then by their memory, as read within the last few seconds: each from the system's own record of its devices, an NVIDIA one from its driver's nvidia-smi, which tells its free memory and the CUDA it runs, and the CUDA of the driver itself where nvidia-smi is not there to say. Empty when the computer has none or the system tells nothing of them

func (GPU) CUDAMajor

func (g GPU) CUDAMajor() int

Major version of the CUDA the driver runs, 0 when it runs none or is not known

func (GPU) DriverTitle

func (g GPU) DriverTitle() string

The driver as a user reads it, its name before its version, such as nvidia 580.65.06; empty when neither is known

func (GPU) Title

func (g GPU) Title() string

Name of the GPU as a user reads it: its own, otherwise its maker's

type Installer

type Installer struct {
	Manager, Package string
}

How a program of the system's own packages is installed on this computer: the package manager that installs it and the name of the package there

func Installs

func Installs(names map[string]string) (Installer, bool)

The first package manager of this system that has the package, under the name each manager gives it. false when none of them does

func (Installer) Args

func (i Installer) Args() []string

Words of the install, asking nothing, without sudo

func (Installer) Command

func (i Installer) Command() string

The command a user types to install the package, sudo before it where they need it

func (Installer) Root

func (i Installer) Root() bool

Whether the manager installs for the whole computer and the user is not root, so it runs through sudo

type Memory

type Memory struct {
	Total, Available int64
}

Memory of this computer as the system tells it, in bytes: in all, and free for new work

func ReadMemory

func ReadMemory() (Memory, bool)

Memory of this computer as /proc/meminfo tells it, the bound of each control group this process runs in lowering both where one is set. false where it can't be read

type Reaping

type Reaping int

What this process does with the processes orphaned below it

const (
	// Nothing: they go to the first process of the system or of the container, as for any program
	Unadopted Reaping = iota
	// This process is the first of its container, and every process orphaned in the container is handed to it
	First
	// This process made itself the reaper of its descendants, and those orphaned below it are handed to it
	Adopting
)

func Adopt

func Adopt() (Reaping, error)

Makes this process the reaper of its descendants, unless it is the first process of its container already, and reaps what is handed to it from now on. How it takes up orphans

func Adopted

func Adopted() (Reaping, int64)

How this process takes up the processes orphaned below it, and how many it reaped so far

type Self

type Self struct {
	// Memory resident now, the part of it no file backs, and the most that was ever resident
	Resident, Anonymous, Peak int64
	// Files, sockets and other handles open
	Files int64
	// Seconds of processor time it took, its own and the system's for it
	User, System float64
}

What the system says of this process, in bytes and seconds; -1 for what it does not say here

func ReadSelf

func ReadSelf() Self

What Linux says of this process: resident and anonymous pages from /proc/self/status, the descriptors open in /proc/self/fd, and the most it was resident and its processor time from getrusage, which counts the most in kilobytes

func (Self) CPU

func (s Self) CPU() float64

Processor time of the process in all, its own and the system's for it; -1 where the system does not say

type Title

type Title struct {
	Server  bool
	Profile string
}

What an icebath process is, as the name ps and top show for it says: the server, or a window on a profile. It never holds what a person wrote, a key or a path: a profile is named only while it is a profile's name, the default one not at all

func (Title) String

func (t Title) String() string

Name the process goes by: icebath, as alpha names every process. Icebath server for the server. Icebath and the profile a window works on when it is not the default one, cut to what the system keeps

Jump to

Keyboard shortcuts

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