Skip to content

Commit 21c1219

Browse files
mheonrh-atomic-bot
authored andcommitted
Alter CGroup path handling for 'podman top'
Signed-off-by: Matthew Heon <[email protected]> Closes: #507 Approved by: baude
1 parent 15ca5f2 commit 21c1219

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libpod/container_top.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package libpod
22

33
import (
4-
"fmt"
54
"io/ioutil"
65
"path/filepath"
76
"strings"
@@ -28,14 +27,20 @@ func (c *Container) GetContainerPids() ([]string, error) {
2827
// Gets the pids for a container without locking. should only be called from a func where
2928
// locking has already been established.
3029
func (c *Container) getContainerPids() ([]string, error) {
31-
taskFile := filepath.Join("/sys/fs/cgroup/pids", c.config.CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID()), c.ID(), "tasks")
30+
cgroupPath, err := c.CGroupPath()("")
31+
if err != nil {
32+
return nil, errors.Wrapf(err, "error getting cgroup path for container %s", c.ID())
33+
}
34+
35+
taskFile := filepath.Join("/sys/fs/cgroup/pids", cgroupPath, "tasks")
36+
3237
logrus.Debug("reading pids from ", taskFile)
38+
3339
content, err := ioutil.ReadFile(taskFile)
3440
if err != nil {
3541
return []string{}, errors.Wrapf(err, "unable to read pids from %s", taskFile)
3642
}
3743
return strings.Fields(string(content)), nil
38-
3944
}
4045

4146
// GetContainerPidInformation calls ps with the appropriate options and returns

0 commit comments

Comments
 (0)