diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/batchcontainer/container.go | 5 | ||||
-rw-r--r-- | cmd/podman/ps.go | 33 |
2 files changed, 23 insertions, 15 deletions
diff --git a/cmd/podman/batchcontainer/container.go b/cmd/podman/batchcontainer/container.go index 76b10b633..6f002f58a 100644 --- a/cmd/podman/batchcontainer/container.go +++ b/cmd/podman/batchcontainer/container.go @@ -38,6 +38,7 @@ type BatchContainerStruct struct { ConConfig *libpod.ContainerConfig ConState libpod.ContainerStatus ExitCode int32 + Exited bool Pid int RootFsSize, RwSize int64 StartedTime time.Time @@ -63,6 +64,7 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru conState libpod.ContainerStatus err error exitCode int32 + exited bool pid int rootFsSize, rwSize int64 startedTime time.Time @@ -75,7 +77,7 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru return errors.Wrapf(err, "unable to obtain container state") } - exitCode, _, err = c.ExitCode() + exitCode, exited, err = c.ExitCode() if err != nil { return errors.Wrapf(err, "unable to obtain container exit code") } @@ -115,6 +117,7 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru ConConfig: conConfig, ConState: conState, ExitCode: exitCode, + Exited: exited, Pid: pid, RootFsSize: rootFsSize, RwSize: rwSize, diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index a5f417449..b659a91a0 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -58,6 +58,7 @@ type psJSONParams struct { Command []string `json:"command"` CreatedAt time.Time `json:"createdAt"` ExitCode int32 `json:"exitCode"` + Exited bool `json:"exited"` RunningFor time.Duration `json:"runningFor"` Status string `json:"status"` PID int `json:"PID"` @@ -576,22 +577,26 @@ func getAndSortJSONParams(containers []*libpod.Container, opts batchcontainer.Ps ns = batchcontainer.GetNamespaces(batchInfo.Pid) } params := psJSONParams{ - ID: ctr.ID(), - Image: batchInfo.ConConfig.RootfsImageName, - ImageID: batchInfo.ConConfig.RootfsImageID, - Command: batchInfo.ConConfig.Spec.Process.Args, - CreatedAt: batchInfo.ConConfig.CreatedTime, - Status: batchInfo.ConState.String(), - Ports: batchInfo.ConConfig.PortMappings, - RootFsSize: batchInfo.RootFsSize, - RWSize: batchInfo.RwSize, - Names: batchInfo.ConConfig.Name, - Labels: batchInfo.ConConfig.Labels, - Mounts: batchInfo.ConConfig.UserVolumes, - Namespaces: ns, + ID: ctr.ID(), + Image: batchInfo.ConConfig.RootfsImageName, + ImageID: batchInfo.ConConfig.RootfsImageID, + Command: batchInfo.ConConfig.Spec.Process.Args, + CreatedAt: batchInfo.ConConfig.CreatedTime, + ExitCode: batchInfo.ExitCode, + Exited: batchInfo.Exited, + Status: batchInfo.ConState.String(), + PID: batchInfo.Pid, + Ports: batchInfo.ConConfig.PortMappings, + RootFsSize: batchInfo.RootFsSize, + RWSize: batchInfo.RwSize, + Names: batchInfo.ConConfig.Name, + Labels: batchInfo.ConConfig.Labels, + Mounts: batchInfo.ConConfig.UserVolumes, + ContainerRunning: batchInfo.ConState == libpod.ContainerStateRunning, + Namespaces: ns, } - if !batchInfo.StartedTime.IsZero() { + if !batchInfo.StartedTime.IsZero() && batchInfo.ConState == libpod.ContainerStateRunning { params.RunningFor = time.Since(batchInfo.StartedTime) } |