mirror of https://github.com/containers/podman.git
Merge pull request #12464 from giuseppe/fix-race-reading-cgroup-file
container, cgroup: detect pid termination
This commit is contained in:
commit
ecc663097a
|
@ -939,6 +939,11 @@ func (c *Container) cGroupPath() (string, error) {
|
||||||
procPath := fmt.Sprintf("/proc/%d/cgroup", c.state.PID)
|
procPath := fmt.Sprintf("/proc/%d/cgroup", c.state.PID)
|
||||||
lines, err := ioutil.ReadFile(procPath)
|
lines, err := ioutil.ReadFile(procPath)
|
||||||
if err != nil {
|
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
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue