summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-03-16 10:15:30 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-11 14:43:57 +0000
commit21c121941510426083f322f60562f1cb19a1fb46 (patch)
treef1af6a5039bd8f36a286cbf7e4b82f783aaab863
parent15ca5f26878e397056d31e84b4f0937ab173645b (diff)
downloadpodman-21c121941510426083f322f60562f1cb19a1fb46.tar.gz
podman-21c121941510426083f322f60562f1cb19a1fb46.tar.bz2
podman-21c121941510426083f322f60562f1cb19a1fb46.zip
Alter CGroup path handling for 'podman top'
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #507 Approved by: baude
-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