Merge pull request #11843 from ahmetalpbalkan/win-cli/monitorttysize

windows: monitorTtySize correctly by polling
This commit is contained in:
Tibor Vass 2015-03-31 11:14:04 -04:00
commit ddbc68f564
1 changed files with 25 additions and 7 deletions

View File

@ -12,8 +12,10 @@ import (
"net/url" "net/url"
"os" "os"
gosignal "os/signal" gosignal "os/signal"
"runtime"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/api" "github.com/docker/docker/api"
@ -279,6 +281,21 @@ func getExecExitCode(cli *DockerCli, execID string) (bool, int, error) {
func (cli *DockerCli) monitorTtySize(id string, isExec bool) error { func (cli *DockerCli) monitorTtySize(id string, isExec bool) error {
cli.resizeTty(id, isExec) cli.resizeTty(id, isExec)
if runtime.GOOS == "windows" {
go func() {
prevW, prevH := cli.getTtySize()
for {
time.Sleep(time.Millisecond * 250)
w, h := cli.getTtySize()
if prevW != w || prevH != h {
cli.resizeTty(id, isExec)
}
prevW = w
prevH = h
}
}()
} else {
sigchan := make(chan os.Signal, 1) sigchan := make(chan os.Signal, 1)
gosignal.Notify(sigchan, signal.SIGWINCH) gosignal.Notify(sigchan, signal.SIGWINCH)
go func() { go func() {
@ -286,6 +303,7 @@ func (cli *DockerCli) monitorTtySize(id string, isExec bool) error {
cli.resizeTty(id, isExec) cli.resizeTty(id, isExec)
} }
}() }()
}
return nil return nil
} }