summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-01 20:59:10 +0100
committerGitHub <noreply@github.com>2021-12-01 20:59:10 +0100
commitecc663097a5791fea01e730308528d67d534e44a (patch)
tree5f4435c2d0894a1af720168c514078148b3e097a
parent078e633294b07027c9f531ac1e849bb5b3d779f8 (diff)
parent0afaf78378f8da3a2fb58617a22baed1268b3e7b (diff)
downloadpodman-ecc663097a5791fea01e730308528d67d534e44a.tar.gz
podman-ecc663097a5791fea01e730308528d67d534e44a.tar.bz2
podman-ecc663097a5791fea01e730308528d67d534e44a.zip
Merge pull request #12464 from giuseppe/fix-race-reading-cgroup-file
container, cgroup: detect pid termination
-rw-r--r--libpod/container.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 482af43f3..2b74a1943 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -939,6 +939,11 @@ func (c *Container) cGroupPath() (string, error) {
procPath := fmt.Sprintf("/proc/%d/cgroup", c.state.PID)
lines, err := ioutil.ReadFile(procPath)
if err != nil {
+ // If the file doesn't exist, it means the container could have been terminated
+ // so report it.
+ if os.IsNotExist(err) {
+ return "", errors.Wrapf(define.ErrCtrStopped, "cannot get cgroup path unless container %s is running", c.ID())
+ }
return "", err
}