Documentation
¶
Index ¶
- Constants
- Variables
- type Controller
- func (c *Controller) ActiveLimits() []LimitInfo
- func (c *Controller) ClearLimit(pid uint32) error
- func (c *Controller) Kill(pid uint32, confirm bool) error
- func (c *Controller) KillTree(rootPID uint32, confirm bool) (int, error)
- func (c *Controller) Limit(pid uint32, cpuPct int, maxBytes uint64, confirm bool) error
- func (c *Controller) Resume(pid uint32) error
- func (c *Controller) SetAffinity(pid uint32, mask uint64, confirm bool) error
- func (c *Controller) SetConfig(cfg *config.Config)
- func (c *Controller) SetPriority(pid uint32, class string, confirm bool) error
- func (c *Controller) Suspend(pid uint32, confirm bool) error
- type LimitInfo
- type Safety
Constants ¶
const ( EventKilled = "controller.killed" EventSuspended = "controller.suspended" EventResumed = "controller.resumed" EventPriority = "controller.priority" EventAffinity = "controller.affinity" EventLimited = "controller.limited" EventLimitCleared = "controller.limit_cleared" )
Event names emitted on successful operations.
Variables ¶
var ( ErrProtected = errors.New("process is protected") ErrCritical = errors.New("process is marked critical by Windows") ErrConfirmNeeded = errors.New("operation requires explicit confirmation") ErrNotFound = errors.New("process not found") ErrSelf = errors.New("operation not allowed on the running Windows Task Manager process") )
Common errors returned by the controller surface.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller exposes process management operations with safety enforcement.
func NewController ¶
func (*Controller) ActiveLimits ¶
func (c *Controller) ActiveLimits() []LimitInfo
ActiveLimits returns a snapshot of every limited process.
func (*Controller) ClearLimit ¶
func (c *Controller) ClearLimit(pid uint32) error
ClearLimit drops the Job Object for a PID, releasing its caps.
func (*Controller) Kill ¶
func (c *Controller) Kill(pid uint32, confirm bool) error
Kill terminates a process. confirm is required for system paths when ConfirmKillSystem is enabled.
func (*Controller) KillTree ¶
func (c *Controller) KillTree(rootPID uint32, confirm bool) (int, error)
KillTree terminates a process and every descendant. Each child must independently pass the safety check.
func (*Controller) Limit ¶
Limit creates a Job Object around the PID and applies CPU/memory caps. cpuPct is 1..100 (0 disables CPU rate control); maxBytes is the working set / process memory cap (0 disables).
func (*Controller) Resume ¶
func (c *Controller) Resume(pid uint32) error
Resume resumes every thread in a previously suspended process.
func (*Controller) SetAffinity ¶
func (c *Controller) SetAffinity(pid uint32, mask uint64, confirm bool) error
SetAffinity restricts a process to a subset of logical CPUs.
func (*Controller) SetConfig ¶
func (c *Controller) SetConfig(cfg *config.Config)
SetConfig hot-swaps the underlying safety config.
func (*Controller) SetPriority ¶
func (c *Controller) SetPriority(pid uint32, class string, confirm bool) error
SetPriority maps a textual class to a Win32 priority class and applies it.
type LimitInfo ¶
type LimitInfo struct {
PID uint32 `json:"pid"`
CPUPct int `json:"cpu_pct"`
MemBytes uint64 `json:"mem_bytes"`
}
LimitInfo describes the active CPU/memory caps for a PID.
type Safety ¶
type Safety struct {
// contains filtered or unexported fields
}
Safety enforces the kill/suspend/limit policies declared in config.