Alter CGroup path handling for 'podman top'
Closes:
Approved by: baude
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
