mirror of
https://github.com/containers/podman.git
synced 2025-05-20 08:36:23 +08:00
oci: exit gracefully if container is already dead
While trying to kill a container with a `signal` we cant do anything if container is already dead so `exit` gracefully instead of trying to delete container again. Get container status from runtime. [ NO NEW TESTS NEEDED ] Signed-off-by: Aditya Rajan <arajan@redhat.com>
This commit is contained in:
@ -407,6 +407,11 @@ func (r *ConmonOCIRuntime) KillContainer(ctr *Container, signal uint, all bool)
|
||||
args = append(args, "kill", ctr.ID(), fmt.Sprintf("%d", signal))
|
||||
}
|
||||
if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, env, r.path, args...); err != nil {
|
||||
// try updating container state but ignore errors we cant do anything if this fails.
|
||||
r.UpdateContainerStatus(ctr)
|
||||
if ctr.state.State == define.ContainerStateExited {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrapf(err, "error sending signal to container %s", ctr.ID())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user