Merge pull request #1002 from crosbymichael/stopped

Return 0 for pid if container is stopped
This commit is contained in:
Daniel, Dao Quang Minh 2016-08-25 18:18:32 +01:00 committed by GitHub
commit 91dd6d2452
2 changed files with 12 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import (
"encoding/json"
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/utils"
"github.com/urfave/cli"
)
@ -130,10 +131,14 @@ func getContainers(context *cli.Context) ([]containerState, error) {
if err != nil {
return nil, err
}
pid := state.BaseState.InitProcessPid
if containerStatus == libcontainer.Stopped {
pid = 0
}
bundle, annotations := utils.Annotations(state.Config.Labels)
s = append(s, containerState{
ID: state.BaseState.ID,
InitProcessPid: state.BaseState.InitProcessPid,
InitProcessPid: pid,
Status: containerStatus.String(),
Bundle: bundle,
Created: state.BaseState.Created,

View File

@ -7,6 +7,7 @@ import (
"os"
"time"
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/utils"
"github.com/urfave/cli"
)
@ -55,11 +56,15 @@ instance of a container.`,
if err != nil {
return err
}
pid := state.BaseState.InitProcessPid
if containerStatus == libcontainer.Stopped {
pid = 0
}
bundle, annotations := utils.Annotations(state.Config.Labels)
cs := cState{
Version: state.BaseState.Config.Version,
ID: state.BaseState.ID,
InitProcessPid: state.BaseState.InitProcessPid,
InitProcessPid: pid,
Status: containerStatus.String(),
Bundle: bundle,
Rootfs: state.BaseState.Config.Rootfs,