diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-12-13 10:19:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-13 10:19:31 +0100 |
commit | 71a0c0f69c992a1840a28201526b211f9055b1b6 (patch) | |
tree | 142891c07239f655b3b6657e690d7736731601c9 /libpod/oci_conmon_linux.go | |
parent | 123e7ea5686a80d6b92486fa88284cfad7b1be6c (diff) | |
parent | bd44fd5c815fc750fd6b60899328564bee74e6e5 (diff) | |
download | podman-71a0c0f69c992a1840a28201526b211f9055b1b6.tar.gz podman-71a0c0f69c992a1840a28201526b211f9055b1b6.tar.bz2 podman-71a0c0f69c992a1840a28201526b211f9055b1b6.zip |
Merge pull request #4692 from mheon/reap_exec_sessions
Reap exec sessions on cleanup and removal
Diffstat (limited to 'libpod/oci_conmon_linux.go')
-rw-r--r-- | libpod/oci_conmon_linux.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index 026b13129..37aa71cbb 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -687,6 +687,28 @@ func (r *ConmonOCIRuntime) ExecStopContainer(ctr *Container, sessionID string, t return nil } +// ExecUpdateStatus checks if the given exec session is still running. +func (r *ConmonOCIRuntime) ExecUpdateStatus(ctr *Container, sessionID string) (bool, error) { + session, ok := ctr.state.ExecSessions[sessionID] + if !ok { + // TODO This should probably be a separate error + return false, errors.Wrapf(define.ErrInvalidArg, "no exec session with ID %s found in container %s", sessionID, ctr.ID()) + } + + logrus.Debugf("Checking status of container %s exec session %s", ctr.ID(), sessionID) + + // Is the session dead? + // Ping the PID with signal 0 to see if it still exists. + if err := unix.Kill(session.PID, 0); err != nil { + if err == unix.ESRCH { + return false, nil + } + return false, errors.Wrapf(err, "error pinging container %s exec session %s PID %d with signal 0", ctr.ID(), sessionID, session.PID) + } + + return true, nil +} + // ExecCleanupContainer cleans up files created when a command is run via // ExecContainer. This includes the attach socket for the exec session. func (r *ConmonOCIRuntime) ExecContainerCleanup(ctr *Container, sessionID string) error { |