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 <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Jun 7, 2023
1 parent 90584b1 commit c6b56dc
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 @@ -577,6 +577,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 c6b56dc

Please sign in to comment.