diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-06-15 11:05:00 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-06-16 16:43:30 +0200 |
commit | 666f555aa52b9f82da9d6ca64cf11e4f5e1e78e8 (patch) | |
tree | 0175dbf916bdb7d4722890191bb5f523f64b202f /pkg/bindings | |
parent | e2f51eeb0693eda026fa509a9decfbdd7e0b74a8 (diff) | |
download | podman-666f555aa52b9f82da9d6ca64cf11e4f5e1e78e8.tar.gz podman-666f555aa52b9f82da9d6ca64cf11e4f5e1e78e8.tar.bz2 podman-666f555aa52b9f82da9d6ca64cf11e4f5e1e78e8.zip |
Fix resize race with podman exec -it
When starting a process with `podman exec -it` the terminal is resized
after the process is started. To fix this allow exec start to accept the
terminal height and width as parameter and let it resize right before
the process is started.
Fixes #10560
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/containers/attach.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/pkg/bindings/containers/attach.go b/pkg/bindings/containers/attach.go index adef1e7c8..cc12c8ab7 100644 --- a/pkg/bindings/containers/attach.go +++ b/pkg/bindings/containers/attach.go @@ -343,7 +343,7 @@ func attachHandleResize(ctx, winCtx context.Context, winChange chan os.Signal, i resizeErr = ResizeContainerTTY(ctx, id, new(ResizeTTYOptions).WithHeight(h).WithWidth(w)) } if resizeErr != nil { - logrus.Warnf("failed to resize TTY: %v", resizeErr) + logrus.Infof("failed to resize TTY: %v", resizeErr) } } @@ -408,6 +408,17 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, options *ExecStar // If we are in TTY mode, we need to set raw mode for the terminal. // TODO: Share all of this with Attach() for containers. needTTY := terminalFile != nil && terminal.IsTerminal(int(terminalFile.Fd())) && isTerm + + body := struct { + Detach bool `json:"Detach"` + TTY bool `json:"Tty"` + Height uint16 `json:"h"` + Width uint16 `json:"w"` + }{ + Detach: false, + TTY: needTTY, + } + if needTTY { state, err := setRawTerminal(terminalFile) if err != nil { @@ -419,13 +430,14 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, options *ExecStar } logrus.SetFormatter(&logrus.TextFormatter{}) }() + w, h, err := terminal.GetSize(int(terminalFile.Fd())) + if err != nil { + logrus.Warnf("failed to obtain TTY size: %v", err) + } + body.Width = uint16(w) + body.Height = uint16(h) } - body := struct { - Detach bool `json:"Detach"` - }{ - Detach: false, - } bodyJSON, err := json.Marshal(body) if err != nil { return err |