Browse code

Fix a leaked process handle of the first container to start on Windows

Signed-off-by: Darren Stahl <darst@microsoft.com>

Darren Stahl authored on 2016/05/26 13:33:50
Showing 1 changed files
... ...
@@ -167,6 +167,10 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
167 167
 		// has exited to avoid a container being dropped on the floor.
168 168
 	}
169 169
 
170
+	if err := process.hcsProcess.Close(); err != nil {
171
+		logrus.Error(err)
172
+	}
173
+
170 174
 	// Assume the container has exited
171 175
 	si := StateInfo{
172 176
 		CommonStateInfo: CommonStateInfo{
... ...
@@ -180,9 +184,6 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
180 180
 
181 181
 	// But it could have been an exec'd process which exited
182 182
 	if !isFirstProcessToStart {
183
-		if err := process.hcsProcess.Close(); err != nil {
184
-			logrus.Error(err)
185
-		}
186 183
 		si.State = StateExitProcess
187 184
 	} else {
188 185
 		updatePending, err := ctr.hcsContainer.HasPendingUpdates()