Skip to content

Commit

Permalink
Windows: Restore console mode on set mode failure
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 83c186f)
Signed-off-by: Tibor Vass <[email protected]>
  • Loading branch information
jstarks authored and Tibor Vass committed Jul 26, 2016
1 parent 4cd455a commit 4319323
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/term/term_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4319323

Please sign in to comment.