Documentation
¶
Index ¶
- Constants
- Variables
- func Alive(pid int) bool
- func CleanupDescendants()
- func CleanupRun(marker string)
- func Configure(cmd *exec.Cmd)
- func ConfigureDetached(cmd *exec.Cmd)
- func Configured(cmd *exec.Cmd) bool
- func EnableSubreaper() error
- func Kill(pid int) error
- func ProcessAlive(pid int) bool
- func ReapExitedChild(pid int) bool
- func SetPriority(pid, priority int)
- func Terminate(pid int) error
- type Group
- type Usage
Constants ¶
const RunMarkerEnv = "CODEAF_DELEGATE_RUN"
Variables ¶
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.
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 CleanupDescendants ¶
func CleanupDescendants()
CleanupDescendants runs only inside the senior-dev engine, which is this run's child subreaper. Its process tree includes detached and environment- sanitized shell children, but no process started by the chat or a sibling run.
func CleanupRun ¶
func CleanupRun(marker string)
CleanupRun is only the host's best-effort sweep after the engine itself was killed with SIGKILL. Normal endings use the engine's parent-link walk above; after SIGKILL the engine cannot do that walk, so the private launch marker can find only descendants that kept it in their environment.
func ConfigureDetached ¶
func Configured ¶
func EnableSubreaper ¶
func EnableSubreaper() error
EnableSubreaper keeps an orphaned shell descendant with the engine after the shell exits, so this run can kill and reap it before releasing its folder.
func ProcessAlive ¶
func ReapExitedChild ¶
func SetPriority ¶
func SetPriority(pid, priority int)
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
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
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
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
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
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.