MCPcopy
hub / github.com/opencontainers/runc / signalAllProcesses

Function signalAllProcesses

libcontainer/init_linux.go:684–720  ·  view source on GitHub ↗

signalAllProcesses freezes then iterates over all the processes inside the manager's cgroups sending the signal s to them.

(m cgroups.Manager, s unix.Signal)

Source from the content-addressed store, hash-verified

682// signalAllProcesses freezes then iterates over all the processes inside the
683// manager's cgroups sending the signal s to them.
684func signalAllProcesses(m cgroups.Manager, s unix.Signal) error {
685 if !m.Exists() {
686 return ErrCgroupNotExist
687 }
688 // Use cgroup.kill, if available.
689 if s == unix.SIGKILL {
690 if p := m.Path(""); p != "" { // Either cgroup v2 or hybrid.
691 err := cgroups.WriteFile(p, "cgroup.kill", "1")
692 if err == nil || !errors.Is(err, os.ErrNotExist) {
693 return err
694 }
695 // Fallback to old implementation.
696 }
697 }
698
699 if err := m.Freeze(cgroups.Frozen); err != nil {
700 logrus.Warn(err)
701 }
702 pids, err := m.GetAllPids()
703 if err != nil {
704 if err := m.Freeze(cgroups.Thawed); err != nil {
705 logrus.Warn(err)
706 }
707 return err
708 }
709 for _, pid := range pids {
710 err := unix.Kill(pid, s)
711 if err != nil && err != unix.ESRCH {
712 logrus.Warnf("kill %d: %v", pid, err)
713 }
714 }
715 if err := m.Freeze(cgroups.Thawed); err != nil {
716 logrus.Warn(err)
717 }
718
719 return nil
720}
721
722// setupPidfd opens a process file descriptor of init process, and sends the
723// file descriptor back to the socket.

Callers 2

SignalMethod · 0.85
destroyFunction · 0.85

Calls 4

ExistsMethod · 0.80
PathMethod · 0.80
FreezeMethod · 0.80
GetAllPidsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…