mirror of
https://github.com/containers/podman.git
synced 2025-07-02 08:47:43 +08:00
oci: terminate all container processes on cleanup
if the container has no pid namespace, they are not killed when the container process ends. In this case, attempt to kill them in the same way. The problem was noticed with toolbox where the exec'ed sessions are not terminated when the container is stopped, blocking the system shutdown. [NO NEW TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -735,6 +735,19 @@ func (c *Container) Cleanup(ctx context.Context) error {
|
|||||||
|
|
||||||
// If we didn't restart, we perform a normal cleanup
|
// If we didn't restart, we perform a normal cleanup
|
||||||
|
|
||||||
|
// make sure all the container processes are terminated if we are running without a pid namespace.
|
||||||
|
hasPidNs := false
|
||||||
|
for _, i := range c.config.Spec.Linux.Namespaces {
|
||||||
|
if i.Type == spec.PIDNamespace {
|
||||||
|
hasPidNs = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasPidNs {
|
||||||
|
// do not fail on errors
|
||||||
|
_ = c.ociRuntime.KillContainer(c, uint(unix.SIGKILL), true)
|
||||||
|
}
|
||||||
|
|
||||||
// Check for running exec sessions
|
// Check for running exec sessions
|
||||||
sessions, err := c.getActiveExecSessions()
|
sessions, err := c.getActiveExecSessions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user