mirror of
https://github.com/containers/podman.git
synced 2025-06-07 07:45:34 +08:00
Merge pull request #3595 from mheon/fix_exec_leak
Remove exec PID files after use to prevent memory leaks
This commit is contained in:
@ -305,6 +305,11 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if exited {
|
if exited {
|
||||||
// If the runtime exited, propagate the error we got from the process.
|
// 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 err
|
||||||
}
|
}
|
||||||
return errors.Wrapf(err, "timed out waiting for runtime to create pidfile for exec session in container %s", c.ID())
|
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
|
// Pidfile exists, read it
|
||||||
contents, err := ioutil.ReadFile(pidFile)
|
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 {
|
if err != nil {
|
||||||
// We don't know the PID of the exec session
|
// We don't know the PID of the exec session
|
||||||
// However, it may still be alive
|
// However, it may still be alive
|
||||||
|
Reference in New Issue
Block a user