mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Handle removing containers with active exec sessions
For containers without --force set, an error will be returned For containers with --force, all pids in the container will be stopped, first with SIGTERM and then with SIGKILL after a timeout (this mimics the behavior of stopping a container). Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #412 Approved by: baude
This commit is contained in:
@ -165,6 +165,17 @@ func (r *Runtime) removeContainer(c *Container, force bool) error {
|
||||
return errors.Wrapf(ErrCtrStateInvalid, "cannot remove container %s as it is %s - running or paused containers cannot be removed", c.ID(), c.state.State.String())
|
||||
}
|
||||
|
||||
// Check that all of our exec sessions have finished
|
||||
if len(c.state.ExecSessions) != 0 {
|
||||
if force {
|
||||
if err := r.ociRuntime.execStopContainer(c, c.StopTimeout()); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return errors.Wrapf(ErrCtrStateInvalid, "cannot remove container %s as it has active exec sessions", c.ID())
|
||||
}
|
||||
}
|
||||
|
||||
// Check that no other containers depend on the container
|
||||
deps, err := r.state.ContainerInUse(c)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user