MCPcopy
hub / github.com/containerd/containerd / KillProcess

Function KillProcess

integration/main_test.go:661–674  ·  view source on GitHub ↗

KillProcess kills the process by name. pkill is used.

(name string, signal syscall.Signal)

Source from the content-addressed store, hash-verified

659
660// KillProcess kills the process by name. pkill is used.
661func KillProcess(name string, signal syscall.Signal) error {
662 var command []string
663 if goruntime.GOOS == "windows" {
664 command = []string{"taskkill", "/IM", name, "/F"}
665 } else {
666 command = []string{"pkill", "-" + strconv.Itoa(int(signal)), "-x", fmt.Sprintf("^%s$", name)}
667 }
668
669 output, err := exec.Command(command[0], command[1:]...).CombinedOutput()
670 if err != nil {
671 return fmt.Errorf("failed to kill %q - error: %v, output: %q", name, err, output)
672 }
673 return nil
674}
675
676// KillPid kills the process by pid. kill is used.
677func KillPid(pid int) error {

Callers 1

RestartContainerdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…