processgroup

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EffectiveCores = effectiveCores

EffectiveCores is how many processor cores this process may ACTUALLY use: the smallest of the machine's logical CPUs, the scheduler affinity mask, and the cgroup CPU quota walked from the process's own cgroup upward. A job subtree's CPU ceiling is a share of THIS and not of the machine's raw core count, because where a job runs the subtree is usually held under a cgroup CPU quota or an affinity mask and can never reach more cores than these; a ceiling drawn from the machine's cores would sit above anything the quota lets the subtree produce and would never trip.

It is a variable so a test — or a caller that already knows the figure — can stand a core count in front of the bound without a cgroup or an affinity mask to be under; nothing but a test reassigns it.

View Source
var OnRefused func(pid int, reason string)

OnRefused, when non-nil, is told why a group signal was withheld. A refusal is the safe answer on its own and needs no record to be safe; a host that wants one hangs it here.

Functions

func Alive

func Alive(pid int) bool

func Configure

func Configure(cmd *exec.Cmd)

func ConfigureDetached

func ConfigureDetached(cmd *exec.Cmd)

func Configured

func Configured(cmd *exec.Cmd) bool

func Kill

func Kill(pid int) error

func ProcessAlive

func ProcessAlive(pid int) bool

func ReapExitedChild

func ReapExitedChild(pid int) bool

func SetPriority

func SetPriority(pid, priority int)

func Terminate

func Terminate(pid int) error

Types

type Group added in v0.3.0

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

Group is a process group recorded when a job starts: the leader's pid and the identity that pid had then.

func CaptureGroup added in v0.3.0

func CaptureGroup(pid int) Group

CaptureGroup records a just-started process-group leader. It is called while the process is known to be this job's own, which is the only moment the identity is trustworthy.

func (Group) Alive added in v0.3.0

func (g Group) Alive() bool

Alive reports whether the recorded group is still there AND still this job's. A group that cannot be attributed is not alive for our purposes: there is nothing of ours left to wait on and nothing of ours to escalate against, and neither is a group whose only remaining member is a zombie (members_linux.go says why that case is asked about at all). It records no refusal because it is polled in a loop; the signals above, sent at most a few times, are what carry the reason.

func (Group) Kill added in v0.3.0

func (g Group) Kill() error

Kill ends a recorded process group, and sends nothing when the recorded identity no longer matches the live process.

func (Group) Terminate added in v0.3.0

func (g Group) Terminate() error

Terminate asks a recorded process group to stop, and sends nothing when the recorded identity no longer matches the live process.

func (Group) Usage added in v0.3.0

func (g Group) Usage() (Usage, bool)

Usage reports what the recorded process group's whole subtree is using, or says it cannot say.

IT REFUSES WHEN THE IDENTITY NO LONGER MATCHES, for [Group.owned]'s reason: the pid may have been reused, and a reading of somebody else's process group is worse than no reading — it could cut a subtree that is not ours. A group that cannot be attributed is one this bound must leave alone.

type Usage added in v0.3.0

type Usage struct {
	// Processes is how many processes are alive in the subtree.
	Processes int
	// CPUSeconds is the subtree's cumulative CPU time in seconds, summed over
	// every process in it. Subtract two readings and divide by the wall between
	// them to get the cores the subtree held.
	CPUSeconds float64
}

Usage is what one job subtree is using at one instant.

Jump to

Keyboard shortcuts

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