diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-07-13 16:35:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 16:35:05 -0400 |
commit | 4729fd425588e17eff4f575d433f1075d4e27bb4 (patch) | |
tree | e7727035759b5c7aa08a745a2f87ae0fd4e546af /libpod/container.go | |
parent | a689639a6502bab3f49b853bc2983c1b44363b2f (diff) | |
parent | 259136c36c89cb32e28edfe8b5d7a3c1082fad5b (diff) | |
download | podman-4729fd425588e17eff4f575d433f1075d4e27bb4.tar.gz podman-4729fd425588e17eff4f575d433f1075d4e27bb4.tar.bz2 podman-4729fd425588e17eff4f575d433f1075d4e27bb4.zip |
Merge pull request #1089 from mheon/add_exited
Record whether the container has exited
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libpod/container.go b/libpod/container.go index f882868ed..38f07bd5b 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -135,6 +135,8 @@ type containerState struct { FinishedTime time.Time `json:"finishedTime,omitempty"` // ExitCode is the exit code returned when the container stopped ExitCode int32 `json:"exitCode,omitempty"` + // Exited is whether the container has exited + Exited bool `json:"exited,omitempty"` // OOMKilled indicates that the container was killed as it ran out of // memory OOMKilled bool `json:"oomKilled,omitempty"` @@ -667,16 +669,18 @@ func (c *Container) FinishedTime() (time.Time, error) { } // ExitCode returns the exit code of the container as -// an int32 -func (c *Container) ExitCode() (int32, error) { +// an int32, and whether the container has exited. +// If the container has not exited, exit code will always be 0. +// If the container restarts, the exit code is reset to 0. +func (c *Container) ExitCode() (int32, bool, error) { if !c.batched { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return 0, errors.Wrapf(err, "error updating container %s state", c.ID()) + return 0, false, errors.Wrapf(err, "error updating container %s state", c.ID()) } } - return c.state.ExitCode, nil + return c.state.ExitCode, c.state.Exited, nil } // OOMKilled returns whether the container was killed by an OOM condition |