{"modulePath":"github.com/Agent-Field/codeaf","version":"v0.8.4","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package processgroup\n\n## Constants\n\n```go\nconst RunMarkerEnv = \"CODEAF_DELEGATE_RUN\"\n```\n\n## Variables\n\n```go\nvar EffectiveCores = effectiveCores\n```\nEffectiveCores 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.\n\nIt 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.\n\n```go\nvar OnRefused func(pid int, reason string)\n```\nOnRefused, 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.\n\n## Functions\n\n```go\nfunc Alive(pid int) bool\n```\n\n```go\nfunc CleanupDescendants()\n```\nCleanupDescendants 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.\n\n```go\nfunc CleanupRun(marker string)\n```\nCleanupRun 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.\n\n```go\nfunc Configure(cmd *exec.Cmd)\n```\n\n```go\nfunc ConfigureDetached(cmd *exec.Cmd)\n```\n\n```go\nfunc Configured(cmd *exec.Cmd) bool\n```\n\n```go\nfunc EnableSubreaper() error\n```\nEnableSubreaper keeps an orphaned shell descendant with the engine after the shell exits, so this run can kill and reap it before releasing its folder.\n\n```go\nfunc Kill(pid int) error\n```\n\n```go\nfunc ProcessAlive(pid int) bool\n```\n\n```go\nfunc ReapExitedChild(pid int) bool\n```\n\n```go\nfunc SetPriority(pid, priority int)\n```\n\n```go\nfunc Terminate(pid int) error\n```\n\n## Types\n\n```go\ntype Group struct {\n\t// contains filtered or unexported fields\n}\n```\nGroup is a process group recorded when a job starts: the leader's pid and the identity that pid had then.\n\n```go\nfunc CaptureGroup(pid int) Group\n```\nCaptureGroup 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.\n\n```go\nfunc (g Group) Alive() bool\n```\nAlive 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.\n\n```go\nfunc (g Group) Kill() error\n```\nKill ends a recorded process group, and sends nothing when the recorded identity no longer matches the live process.\n\n```go\nfunc (g Group) Terminate() error\n```\nTerminate asks a recorded process group to stop, and sends nothing when the recorded identity no longer matches the live process.\n\n```go\nfunc (g Group) Usage() (Usage, bool)\n```\nUsage reports what the recorded process group's whole subtree is using, or says it cannot say.\n\nIT 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.\n\n```go\ntype Usage struct {\n\t// Processes is how many processes are alive in the subtree.\n\tProcesses int\n\t// CPUSeconds is the subtree's cumulative CPU time in seconds, summed over\n\t// every process in it. Subtract two readings and divide by the wall between\n\t// them to get the cores the subtree held.\n\tCPUSeconds float64\n}\n```\nUsage is what one job subtree is using at one instant.\n\n","path":"github.com/Agent-Field/codeaf/internal/processgroup","name":"processgroup","synopsis":"","isRedistributable":true}
