diff --git a/daemon/execdriver/driver.go b/daemon/execdriver/driver.go index 6a698a618049576cf45789e38282d0131f61751c..859eaa74f586595465e204d3a995201e96c44fab 100644 --- a/daemon/execdriver/driver.go +++ b/daemon/execdriver/driver.go @@ -52,15 +52,6 @@ type Terminal interface { Resize(height, width int) error } -// ExitStatus provides exit reasons for a container. -type ExitStatus struct { - // The exit code with which the container exited. - ExitCode int - - // Whether the container encountered an OOM. - OOMKilled bool -} - // Driver is an interface for drivers to implement // including all basic functions a driver should have type Driver interface { diff --git a/daemon/execdriver/driver_unix.go b/daemon/execdriver/driver_unix.go index ab49ba650f1c94a3a6163ad9adb626eed45ecdfd..2e800c088e6821078960669e0e01f76befa861f2 100644 --- a/daemon/execdriver/driver_unix.go +++ b/daemon/execdriver/driver_unix.go @@ -262,3 +262,12 @@ type User struct { UID int `json:"root_uid"` GID int `json:"root_gid"` } + +// ExitStatus provides exit reasons for a container. +type ExitStatus struct { + // The exit code with which the container exited. + ExitCode int + + // Whether the container encountered an OOM. + OOMKilled bool +} diff --git a/daemon/execdriver/driver_windows.go b/daemon/execdriver/driver_windows.go index 9419519e49721c7b26f7a623411722e92b4d0130..1336ba97f01d84f21a0585b520a8ed6636e073a8 100644 --- a/daemon/execdriver/driver_windows.go +++ b/daemon/execdriver/driver_windows.go @@ -46,3 +46,9 @@ type Command struct { LayerPaths []string `json:"layer_paths"` // Layer paths for a command Isolated bool `json:"isolated"` // True if a Hyper-V container } + +// ExitStatus provides exit reasons for a container. +type ExitStatus struct { + // The exit code with which the container exited. + ExitCode int +} diff --git a/daemon/state.go b/daemon/state.go index b9231f2a6c9726d959635af128b8320e6b937c47..8ff5effc637c2b0e9c345e9b51831862c96120ec 100644 --- a/daemon/state.go +++ b/daemon/state.go @@ -201,8 +201,7 @@ func (s *State) setStopped(exitStatus *execdriver.ExitStatus) { s.Restarting = false s.Pid = 0 s.FinishedAt = time.Now().UTC() - s.ExitCode = exitStatus.ExitCode - s.OOMKilled = exitStatus.OOMKilled + s.setFromExitStatus(exitStatus) close(s.waitChan) // fire waiters for stop s.waitChan = make(chan struct{}) } @@ -222,8 +221,7 @@ func (s *State) setRestarting(exitStatus *execdriver.ExitStatus) { s.Restarting = true s.Pid = 0 s.FinishedAt = time.Now().UTC() - s.ExitCode = exitStatus.ExitCode - s.OOMKilled = exitStatus.OOMKilled + s.setFromExitStatus(exitStatus) close(s.waitChan) // fire waiters for stop s.waitChan = make(chan struct{}) } diff --git a/daemon/state_unix.go b/daemon/state_unix.go new file mode 100644 index 0000000000000000000000000000000000000000..e5f4db33faeb733beb919b7e77ec5239f31bd0f0 --- /dev/null +++ b/daemon/state_unix.go @@ -0,0 +1,12 @@ +// +build linux freebsd + +package daemon + +import "github.com/docker/docker/daemon/execdriver" + +// setFromExitStatus is a platform specific helper function to set the state +// based on the ExitStatus structure. +func (s *State) setFromExitStatus(exitStatus *execdriver.ExitStatus) { + s.ExitCode = exitStatus.ExitCode + s.OOMKilled = exitStatus.OOMKilled +} diff --git a/daemon/state_windows.go b/daemon/state_windows.go new file mode 100644 index 0000000000000000000000000000000000000000..223d4bc50bbd7439cef86df4e0bdb70070597b0f --- /dev/null +++ b/daemon/state_windows.go @@ -0,0 +1,9 @@ +package daemon + +import "github.com/docker/docker/daemon/execdriver" + +// setFromExitStatus is a platform specific helper function to set the state +// based on the ExitStatus structure. +func (s *State) setFromExitStatus(exitStatus *execdriver.ExitStatus) { + s.ExitCode = exitStatus.ExitCode +}