From c2df6e08cf6d06b194b31b2bc9778f5f0b30d198 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 26 Apr 2016 14:40:05 -0700 Subject: [PATCH] Use runc for getting list of processes runc now has a `ps` command with json output to support listing all the processes inside a container. We no longer need to use libcontainer directly for doing this. Signed-off-by: Michael Crosby --- runtime/container.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/container.go b/runtime/container.go index 933fc05..144298c 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -521,11 +521,15 @@ func hostIDFromMap(id uint32, mp []ocs.IDMapping) int { } func (c *container) Pids() ([]int, error) { - container, err := c.getLibctContainer() + out, err := exec.Command(c.runtime, "ps", "--format=json", c.id).CombinedOutput() if err != nil { + return nil, fmt.Errorf(string(out)) + } + var pids []int + if err := json.Unmarshal(out, &pids); err != nil { return nil, err } - return container.Processes() + return pids, nil } func (c *container) Stats() (*Stat, error) {