Created
July 14, 2015 20:43
-
-
Save termie/29d0d711e376812d5f10 to your computer and use it in GitHub Desktop.
kill stuff in a container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// killProcesses sends a signal to all the processes on the machine except | |
// for PID 1, somewhat naive but seems to work | |
func (s *WatchStep) killProcesses(containerID string, signal string) error { | |
client, err := NewDockerClient(s.options.DockerOptions) | |
if err != nil { | |
return err | |
} | |
cmd := []string{`/bin/sh`, `-c`, fmt.Sprintf(`ps | grep -v PID | awk "{if (\$1 != 1) print \$1}" | xargs -n 1 kill -s %s`, signal)} | |
err = client.ExecOne(containerID, cmd, os.Stdout) | |
if err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment