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 <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-04-26 14:40:05 -07:00
parent f279c4a878
commit c2df6e08cf

View file

@ -521,11 +521,15 @@ func hostIDFromMap(id uint32, mp []ocs.IDMapping) int {
} }
func (c *container) Pids() ([]int, error) { 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 { if err != nil {
return nil, fmt.Errorf(string(out))
}
var pids []int
if err := json.Unmarshal(out, &pids); err != nil {
return nil, err return nil, err
} }
return container.Processes() return pids, nil
} }
func (c *container) Stats() (*Stat, error) { func (c *container) Stats() (*Stat, error) {