cli: move setRawTerminal and restoreTerminal to holdHijackedConnection
In this way, we can restore the Terminal as soon as possible once the hijacked connection end. This not only fix weird output if cli enable -D, but also remove duplicate code. Signed-off-by: Lei Jitang <leijitang@huawei.com> Upstream-commit: 66d3dcc6f7648ab5af3c7f876c2b9c63ab2899ac Component: engine
This commit is contained in:
@ -71,12 +71,6 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Close()
|
||||
if in != nil && c.Config.Tty {
|
||||
if err := cli.setRawTerminal(); err != nil {
|
||||
return err
|
||||
}
|
||||
defer cli.restoreTerminal(in)
|
||||
}
|
||||
|
||||
if c.Config.Tty && cli.isTerminalOut {
|
||||
height, width := cli.getTtySize()
|
||||
@ -92,8 +86,7 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
|
||||
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(context.Background(), c.Config.Tty, in, cli.out, cli.err, resp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user