From 0532dcf3dc1fa34fab5a9cdee6c4d87af66a6cdf Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Thu, 26 Mar 2015 15:11:28 -0700 Subject: [PATCH] term/winconsole: Identify tty correctly, fix resize problem This change fixes a bug where stdout/stderr handles are not identified correctly. Previously we used to set the window size to fixed size to fit the default tty size on the host (80x24). Now the attach/exec commands can correctly get the terminal size from windows. We still do not `monitorTtySize()` correctly on windows and update the tty size on the host-side, in order to fix that we'll provide a platform-specific `monitorTtySize` implementation in the future. Signed-off-by: Ahmet Alp Balkan --- pkg/term/winconsole/console_windows.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/term/winconsole/console_windows.go b/pkg/term/winconsole/console_windows.go index 19977b1010..85544493f1 100644 --- a/pkg/term/winconsole/console_windows.go +++ b/pkg/term/winconsole/console_windows.go @@ -241,8 +241,6 @@ func StdStreams() (stdIn io.ReadCloser, stdOut io.Writer, stdErr io.Writer) { } handler.screenBufferInfo = screenBufferInfo - // Set the window size - SetWindowSize(stdoutHandle, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_HEIGHT) buffer = make([]CHAR_INFO, screenBufferInfo.MaximumWindowSize.X*screenBufferInfo.MaximumWindowSize.Y) stdOut = &terminalWriter{ @@ -283,6 +281,12 @@ func GetHandleInfo(in interface{}) (uintptr, bool) { isTerminalIn = IsTerminal(inFd) } } + if tr, ok := in.(*terminalWriter); ok { + if file, ok := tr.wrappedWriter.(*os.File); ok { + inFd = file.Fd() + isTerminalIn = IsTerminal(inFd) + } + } return inFd, isTerminalIn }