mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #19835 from ncdc/resize-after-attach
Move resize after attaching
This commit is contained in:
commit
c2ebdb3e57
2 changed files with 19 additions and 6 deletions
|
@ -41,12 +41,6 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Config.Tty && cli.isTerminalOut {
|
|
||||||
if err := cli.monitorTtySize(cmd.Arg(0), false); err != nil {
|
|
||||||
logrus.Debugf("Error monitoring TTY size: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if *detachKeys != "" {
|
if *detachKeys != "" {
|
||||||
cli.configFile.DetachKeys = *detachKeys
|
cli.configFile.DetachKeys = *detachKeys
|
||||||
}
|
}
|
||||||
|
@ -82,6 +76,21 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
|
||||||
defer cli.restoreTerminal(in)
|
defer cli.restoreTerminal(in)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Config.Tty && cli.isTerminalOut {
|
||||||
|
height, width := cli.getTtySize()
|
||||||
|
// To handle the case where a user repeatedly attaches/detaches without resizing their
|
||||||
|
// terminal, the only way to get the shell prompt to display for attaches 2+ is to artifically
|
||||||
|
// resize it, then go back to normal. Without this, every attach after the first will
|
||||||
|
// require the user to manually resize or hit enter.
|
||||||
|
cli.resizeTtyTo(cmd.Arg(0), height+1, width+1, false)
|
||||||
|
|
||||||
|
// After the above resizing occurs, the call to monitorTtySize below will handle resetting back
|
||||||
|
// to the actual size.
|
||||||
|
if err := cli.monitorTtySize(cmd.Arg(0), false); err != nil {
|
||||||
|
logrus.Debugf("Error monitoring TTY size: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := cli.holdHijackedConnection(c.Config.Tty, in, cli.out, cli.err, resp); err != nil {
|
if err := cli.holdHijackedConnection(c.Config.Tty, in, cli.out, cli.err, resp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,10 @@ func (cli *DockerCli) registryAuthenticationPrivilegedFunc(index *registrytypes.
|
||||||
|
|
||||||
func (cli *DockerCli) resizeTty(id string, isExec bool) {
|
func (cli *DockerCli) resizeTty(id string, isExec bool) {
|
||||||
height, width := cli.getTtySize()
|
height, width := cli.getTtySize()
|
||||||
|
cli.resizeTtyTo(id, height, width, isExec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cli *DockerCli) resizeTtyTo(id string, height, width int, isExec bool) {
|
||||||
if height == 0 && width == 0 {
|
if height == 0 && width == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue