package cgroup import ( "errors" "fmt" "os" "os/exec" "path/filepath" "slices" "strconv" "strings" "syscall" "github.com/carlosframework/platform/internal/controlname" ) // The generation layout (zero-downtime deploys spec §7.3). A host's // carlos-exec@ becomes a PARENT that holds no processes. Each // instance spawn lands in its own generation child g, which carries the // tier's full limits and memory.oom.group=1, so a successor that overruns // dies alone and the incumbent is untouched. The legacy co-spawned sidecar // and the seed land in role- children with no limit of their own. The // parent carries the tier with memory.oom.group=0: a backstop for the // instance as a whole, raised to OverlapLimit while two generations run. // Nothing here runs unless the exec backend's GenContainment is set // (plan 5's CARLOS_SWAP). // GenChild is generation n's child cgroup: "g". func GenChild(n uint64) string { return "g" + strconv.FormatUint(n, 10) } // RoleChild is the child cgroup a non-generation spawn of a host lands in // under the generation layout: "role-", the name PrepareRoleChild // pins. func RoleChild(role string) string { return "role-" + role } // isChildName reports whether name is one of the layout's child names: // g with n canonical and above zero, or role-