From 43193233f878bd955e5f527bde3a30bb15c18d5f Mon Sep 17 00:00:00 2001 From: John Starks Date: Fri, 22 Jul 2016 18:34:14 -0700 Subject: [PATCH] Windows: Restore console mode on set mode failure SetConsoleMode() on input handles appears to remember invalid bits that were set, causing problems for other programs (such as xcopy.exe) trying to set the console mode after docker.exe has exited. Always restore the input console mode on set failure. Signed-off-by: John Starks (cherry picked from commit 83c186fdd4332b8a08db715e8cb5dd1e80a56567) Signed-off-by: Tibor Vass --- pkg/term/term_windows.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/term/term_windows.go b/pkg/term/term_windows.go index dbe46788409..dc50da4577a 100644 --- a/pkg/term/term_windows.go +++ b/pkg/term/term_windows.go @@ -44,9 +44,11 @@ func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) { if err = winterm.SetConsoleMode(fd, mode|enableVirtualTerminalInput); err != nil { emulateStdin = true } else { - winterm.SetConsoleMode(fd, mode) vtInputSupported = true } + // Unconditionally set the console mode back even on failure because SetConsoleMode + // remembers invalid bits on input handles. + winterm.SetConsoleMode(fd, mode) } fd = os.Stdout.Fd()