Skip to content

Commit

Permalink
libct: implement support for cgroup.kill
Browse files Browse the repository at this point in the history
Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed May 13, 2023
1 parent 8513d24 commit 9cc045c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,17 @@ func setupRlimits(limits []configs.Rlimit, pid int) error {
// signalAllProcesses freezes then iterates over all the processes inside the
// manager's cgroups sending the signal s to them.
func signalAllProcesses(m cgroups.Manager, s unix.Signal) error {
// Use cgroup.kill, if available.
if s == unix.SIGKILL {
if p := m.Path(""); p != "" { // Either cgroup v2 or hybrid.
err := cgroups.WriteFile(p, "cgroup.kill", "1")
if err == nil || !errors.Is(err, os.ErrNotExist) {
return err
}
// Fallback to old implementation.
}
}

if err := m.Freeze(configs.Frozen); err != nil {
logrus.Warn(err)
}
Expand Down

0 comments on commit 9cc045c

Please sign in to comment.