Skip to content

Commit

Permalink
Merge pull request #12464 from giuseppe/fix-race-reading-cgroup-file
Browse files Browse the repository at this point in the history
container, cgroup: detect pid termination
  • Loading branch information
openshift-merge-robot authored Dec 1, 2021
2 parents 078e633 + 0afaf78 commit ecc6630
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libpod/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ecc6630

Please sign in to comment.