From 21c121941510426083f322f60562f1cb19a1fb46 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 16 Mar 2018 10:15:30 -0400 Subject: Alter CGroup path handling for 'podman top' Signed-off-by: Matthew Heon Closes: #507 Approved by: baude --- libpod/container_top.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libpod/container_top.go b/libpod/container_top.go index 28c1e33d2..16030e040 100644 --- a/libpod/container_top.go +++ b/libpod/container_top.go @@ -1,7 +1,6 @@ package libpod import ( - "fmt" "io/ioutil" "path/filepath" "strings" @@ -28,14 +27,20 @@ func (c *Container) GetContainerPids() ([]string, error) { // Gets the pids for a container without locking. should only be called from a func where // locking has already been established. func (c *Container) getContainerPids() ([]string, error) { - taskFile := filepath.Join("/sys/fs/cgroup/pids", c.config.CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID()), c.ID(), "tasks") + cgroupPath, err := c.CGroupPath()("") + if err != nil { + return nil, errors.Wrapf(err, "error getting cgroup path for container %s", c.ID()) + } + + taskFile := filepath.Join("/sys/fs/cgroup/pids", cgroupPath, "tasks") + logrus.Debug("reading pids from ", taskFile) + content, err := ioutil.ReadFile(taskFile) if err != nil { return []string{}, errors.Wrapf(err, "unable to read pids from %s", taskFile) } return strings.Fields(string(content)), nil - } // GetContainerPidInformation calls ps with the appropriate options and returns -- cgit v1.2.3-54-g00ecf