浏览代码

Merge pull request #23009 from Microsoft/WindowsLeakedHandle

Fix a leaked process handle of the first container to start on Windows
Alexander Morozov 9 年之前
父节点
当前提交
11ddfa4b2b
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      libcontainerd/container_windows.go

+ 4 - 3
libcontainerd/container_windows.go

@@ -167,6 +167,10 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
 		// has exited to avoid a container being dropped on the floor.
 	}
 
+	if err := process.hcsProcess.Close(); err != nil {
+		logrus.Error(err)
+	}
+
 	// Assume the container has exited
 	si := StateInfo{
 		CommonStateInfo: CommonStateInfo{
@@ -180,9 +184,6 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
 
 	// But it could have been an exec'd process which exited
 	if !isFirstProcessToStart {
-		if err := process.hcsProcess.Close(); err != nil {
-			logrus.Error(err)
-		}
 		si.State = StateExitProcess
 	} else {
 		updatePending, err := ctr.hcsContainer.HasPendingUpdates()