Skip to content

Commit

Permalink
term/winconsole: Identify tty correctly, fix resize problem
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ahmetb committed Mar 26, 2015
1 parent 42f9594 commit 0532dcf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/term/winconsole/console_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 0532dcf

Please sign in to comment.