summaryrefslogtreecommitdiff
path: root/cmd/podman/kill.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-11-07 13:20:43 -0600
committerbaude <bbaude@redhat.com>2018-11-08 15:18:11 -0600
commit2dd9cae37cb076418393ba61c0fb7b8cf97148f3 (patch)
tree346e95940f263a5ea770be6f11ebe4130e8e626b /cmd/podman/kill.go
parentfa8cc1a94281aac1c52952a002f9c3dd31d91197 (diff)
downloadpodman-2dd9cae37cb076418393ba61c0fb7b8cf97148f3.tar.gz
podman-2dd9cae37cb076418393ba61c0fb7b8cf97148f3.tar.bz2
podman-2dd9cae37cb076418393ba61c0fb7b8cf97148f3.zip
rm -f now removes a paused container
We now can remove a paused container by sending it a kill signal while it is paused. We then unpause the container and it is immediately killed. Also, reworked how the parallelWorker results are handled to provide a more consistent approach to how each subcommand implements it. It also fixes a bug where if one container errors, the error message is duplicated when printed out. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/kill.go')
-rw-r--r--cmd/podman/kill.go23
1 files changed, 7 insertions, 16 deletions
diff --git a/cmd/podman/kill.go b/cmd/podman/kill.go
index 27882aeee..cfe4b4218 100644
--- a/cmd/podman/kill.go
+++ b/cmd/podman/kill.go
@@ -43,7 +43,6 @@ var (
// killCmd kills one or more containers with a signal
func killCmd(c *cli.Context) error {
var (
- lastError error
killFuncs []shared.ParallelWorkerInput
killSignal uint = uint(syscall.SIGTERM)
)
@@ -75,8 +74,12 @@ func killCmd(c *cli.Context) error {
containers, err := getAllOrLatestContainers(c, runtime, libpod.ContainerStateRunning, "running")
if err != nil {
- return err
+ if len(containers) == 0 {
+ return err
+ }
+ fmt.Println(err.Error())
}
+
for _, ctr := range containers {
con := ctr
f := func() error {
@@ -95,18 +98,6 @@ func killCmd(c *cli.Context) error {
}
logrus.Debugf("Setting maximum workers to %d", maxWorkers)
- killErrors := shared.ParallelExecuteWorkerPool(maxWorkers, killFuncs)
-
- for cid, result := range killErrors {
- if result != nil {
- if len(killErrors) > 1 {
- fmt.Println(result.Error())
- }
- lastError = result
- continue
- }
- fmt.Println(cid)
- }
-
- return lastError
+ killErrors, errCount := shared.ParallelExecuteWorkerPool(maxWorkers, killFuncs)
+ return printParallelOutput(killErrors, errCount)
}