summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/container_top.go11
1 files 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