summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-18 15:52:57 +0200
committerGitHub <noreply@github.com>2019-07-18 15:52:57 +0200
commit22e62e8691495dd5385e23e51901b357e2891a74 (patch)
treeb4698188884cecb511f8b1951cc4752d2819482a /libpod
parentadcde2383f1da517c5788516d639745f5f01d300 (diff)
parent5bbede9d9f5b5ba05bdfb9a20815df9622e9b8f9 (diff)
downloadpodman-22e62e8691495dd5385e23e51901b357e2891a74.tar.gz
podman-22e62e8691495dd5385e23e51901b357e2891a74.tar.bz2
podman-22e62e8691495dd5385e23e51901b357e2891a74.zip
Merge pull request #3595 from mheon/fix_exec_leak
Remove exec PID files after use to prevent memory leaks
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 3577b8e8c..ae181887e 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -305,6 +305,11 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir
if err != nil {
if exited {
// If the runtime exited, propagate the error we got from the process.
+ // We need to remove PID files to ensure no memory leaks
+ if err2 := os.Remove(pidFile); err2 != nil {
+ logrus.Errorf("Error removing exit file for container %s exec session %s: %v", c.ID(), sessionID, err2)
+ }
+
return err
}
return errors.Wrapf(err, "timed out waiting for runtime to create pidfile for exec session in container %s", c.ID())
@@ -312,6 +317,10 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir
// Pidfile exists, read it
contents, err := ioutil.ReadFile(pidFile)
+ // We need to remove PID files to ensure no memory leaks
+ if err2 := os.Remove(pidFile); err2 != nil {
+ logrus.Errorf("Error removing exit file for container %s exec session %s: %v", c.ID(), sessionID, err2)
+ }
if err != nil {
// We don't know the PID of the exec session
// However, it may still be alive