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/api/handlers/compat | |
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/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/exec.go | 10 | ||||
-rw-r--r-- | pkg/api/handlers/compat/resize.go | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go index 1b7b884e0..77e62c112 100644 --- a/pkg/api/handlers/compat/exec.go +++ b/pkg/api/handlers/compat/exec.go @@ -178,8 +178,16 @@ func ExecStartHandler(w http.ResponseWriter, r *http.Request) { logrus.Error(errors.Wrapf(e, "error attaching to container %s exec session %s", sessionCtr.ID(), sessionID)) } + var size *define.TerminalSize + if bodyParams.Tty && (bodyParams.Height > 0 || bodyParams.Width > 0) { + size = &define.TerminalSize{ + Height: bodyParams.Height, + Width: bodyParams.Width, + } + } + hijackChan := make(chan bool, 1) - err = sessionCtr.ExecHTTPStartAndAttach(sessionID, r, w, nil, nil, nil, hijackChan) + err = sessionCtr.ExecHTTPStartAndAttach(sessionID, r, w, nil, nil, nil, hijackChan, size) if <-hijackChan { // If connection was Hijacked, we have to signal it's being closed diff --git a/pkg/api/handlers/compat/resize.go b/pkg/api/handlers/compat/resize.go index f65e313fc..844fb74c4 100644 --- a/pkg/api/handlers/compat/resize.go +++ b/pkg/api/handlers/compat/resize.go @@ -73,7 +73,7 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) { return } if err := ctnr.ExecResize(name, sz); err != nil { - if errors.Cause(err) != define.ErrCtrStateInvalid || !query.IgnoreNotRunning { + if errors.Cause(err) != define.ErrExecSessionStateInvalid || !query.IgnoreNotRunning { utils.InternalServerError(w, errors.Wrapf(err, "cannot resize session")) return } |