Browse code

Windows: Don't close client stdin handle to avoid hang

Signed-off-by: John Howard (VM) <jhoward@microsoft.com>

John Howard (VM) authored on 2017/03/22 07:55:18
Showing 1 changed files
... ...
@@ -105,11 +105,19 @@ func setRawTerminal(streams command.Streams) error {
105 105
 func restoreTerminal(streams command.Streams, in io.Closer) error {
106 106
 	streams.In().RestoreTerminal()
107 107
 	streams.Out().RestoreTerminal()
108
-	// WARNING: DO NOT REMOVE THE OS CHECK !!!
108
+	// WARNING: DO NOT REMOVE THE OS CHECKS !!!
109 109
 	// For some reason this Close call blocks on darwin..
110
-	// As the client exists right after, simply discard the close
110
+	// As the client exits right after, simply discard the close
111 111
 	// until we find a better solution.
112
-	if in != nil && runtime.GOOS != "darwin" {
112
+	//
113
+	// This can also cause the client on Windows to get stuck in Win32 CloseHandle()
114
+	// in some cases. See https://github.com/docker/docker/issues/28267#issuecomment-288237442
115
+	// Tracked internally at Microsoft by VSO #11352156. In the
116
+	// Windows case, you hit this if you are using the native/v2 console,
117
+	// not the "legacy" console, and you start the client in a new window. eg
118
+	// `start docker run --rm -it microsoft/nanoserver cmd /s /c echo foobar`
119
+	// will hang. Remove start, and it won't repro.
120
+	if in != nil && runtime.GOOS != "darwin" && runtime.GOOS != "windows" {
113 121
 		return in.Close()
114 122
 	}
115 123
 	return nil