Windows: Refactor exitStatus structure
| ... | ... |
@@ -52,15 +52,6 @@ type Terminal interface {
|
| 52 | 52 |
Resize(height, width int) error |
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 |
-// ExitStatus provides exit reasons for a container. |
|
| 56 |
-type ExitStatus struct {
|
|
| 57 |
- // The exit code with which the container exited. |
|
| 58 |
- ExitCode int |
|
| 59 |
- |
|
| 60 |
- // Whether the container encountered an OOM. |
|
| 61 |
- OOMKilled bool |
|
| 62 |
-} |
|
| 63 |
- |
|
| 64 | 55 |
// Driver is an interface for drivers to implement |
| 65 | 56 |
// including all basic functions a driver should have |
| 66 | 57 |
type Driver interface {
|
| ... | ... |
@@ -262,3 +262,12 @@ type User struct {
|
| 262 | 262 |
UID int `json:"root_uid"` |
| 263 | 263 |
GID int `json:"root_gid"` |
| 264 | 264 |
} |
| 265 |
+ |
|
| 266 |
+// ExitStatus provides exit reasons for a container. |
|
| 267 |
+type ExitStatus struct {
|
|
| 268 |
+ // The exit code with which the container exited. |
|
| 269 |
+ ExitCode int |
|
| 270 |
+ |
|
| 271 |
+ // Whether the container encountered an OOM. |
|
| 272 |
+ OOMKilled bool |
|
| 273 |
+} |
| ... | ... |
@@ -46,3 +46,9 @@ type Command struct {
|
| 46 | 46 |
LayerPaths []string `json:"layer_paths"` // Layer paths for a command |
| 47 | 47 |
Isolated bool `json:"isolated"` // True if a Hyper-V container |
| 48 | 48 |
} |
| 49 |
+ |
|
| 50 |
+// ExitStatus provides exit reasons for a container. |
|
| 51 |
+type ExitStatus struct {
|
|
| 52 |
+ // The exit code with which the container exited. |
|
| 53 |
+ ExitCode int |
|
| 54 |
+} |
| ... | ... |
@@ -201,8 +201,7 @@ func (s *State) setStopped(exitStatus *execdriver.ExitStatus) {
|
| 201 | 201 |
s.Restarting = false |
| 202 | 202 |
s.Pid = 0 |
| 203 | 203 |
s.FinishedAt = time.Now().UTC() |
| 204 |
- s.ExitCode = exitStatus.ExitCode |
|
| 205 |
- s.OOMKilled = exitStatus.OOMKilled |
|
| 204 |
+ s.setFromExitStatus(exitStatus) |
|
| 206 | 205 |
close(s.waitChan) // fire waiters for stop |
| 207 | 206 |
s.waitChan = make(chan struct{})
|
| 208 | 207 |
} |
| ... | ... |
@@ -222,8 +221,7 @@ func (s *State) setRestarting(exitStatus *execdriver.ExitStatus) {
|
| 222 | 222 |
s.Restarting = true |
| 223 | 223 |
s.Pid = 0 |
| 224 | 224 |
s.FinishedAt = time.Now().UTC() |
| 225 |
- s.ExitCode = exitStatus.ExitCode |
|
| 226 |
- s.OOMKilled = exitStatus.OOMKilled |
|
| 225 |
+ s.setFromExitStatus(exitStatus) |
|
| 227 | 226 |
close(s.waitChan) // fire waiters for stop |
| 228 | 227 |
s.waitChan = make(chan struct{})
|
| 229 | 228 |
} |
| 230 | 229 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,12 @@ |
| 0 |
+// +build linux freebsd |
|
| 1 |
+ |
|
| 2 |
+package daemon |
|
| 3 |
+ |
|
| 4 |
+import "github.com/docker/docker/daemon/execdriver" |
|
| 5 |
+ |
|
| 6 |
+// setFromExitStatus is a platform specific helper function to set the state |
|
| 7 |
+// based on the ExitStatus structure. |
|
| 8 |
+func (s *State) setFromExitStatus(exitStatus *execdriver.ExitStatus) {
|
|
| 9 |
+ s.ExitCode = exitStatus.ExitCode |
|
| 10 |
+ s.OOMKilled = exitStatus.OOMKilled |
|
| 11 |
+} |
| 0 | 12 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,9 @@ |
| 0 |
+package daemon |
|
| 1 |
+ |
|
| 2 |
+import "github.com/docker/docker/daemon/execdriver" |
|
| 3 |
+ |
|
| 4 |
+// setFromExitStatus is a platform specific helper function to set the state |
|
| 5 |
+// based on the ExitStatus structure. |
|
| 6 |
+func (s *State) setFromExitStatus(exitStatus *execdriver.ExitStatus) {
|
|
| 7 |
+ s.ExitCode = exitStatus.ExitCode |
|
| 8 |
+} |