Skip to content

Commit

Permalink
Merge pull request containers#17025 from giuseppe/terminate-processes…
Browse files Browse the repository at this point in the history
…-no-pid-namespace

oci: terminate all container processes on cleanup
  • Loading branch information
openshift-merge-robot authored Jan 8, 2023
2 parents c83a2f8 + 9fe86ec commit 74a961a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libpod/container_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,19 @@ func (c *Container) Cleanup(ctx context.Context) error {

// 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
sessions, err := c.getActiveExecSessions()
if err != nil {
Expand Down

0 comments on commit 74a961a

Please sign in to comment.