Skip to content

exec: honor ConsoleSize so the terminal is sized at creation#28957

Open
shuaiyuanxx wants to merge 1 commit into
podman-container-tools:mainfrom
shuaiyuanxx:exec-honor-console-size
Open

exec: honor ConsoleSize so the terminal is sized at creation#28957
shuaiyuanxx wants to merge 1 commit into
podman-container-tools:mainfrom
shuaiyuanxx:exec-honor-console-size

Conversation

@shuaiyuanxx

Copy link
Copy Markdown

What this does

The exec API accepts a ConsoleSize, but it is dropped: the exec pseudo-terminal is created at its default size and only corrected afterwards by an asynchronous resize. A short-lived exec that reads its window size at startup (e.g. stty size) can
therefore observe the wrong size, because the resize may arrive after the process has already read it. Docker applies the size at creation.

This change carries the requested ConsoleSize through ExecConfig and into the exec OCI process spec (process.consoleSize), so the runtime sizes the terminal before the process starts, removing the race. The local and remote CLIs capture the caller's terminal size when -t is given and pass it through ExecOptions, matching the behavior of podman run.

How to test

$ podman run -d --name c $IMAGE top
$ podman exec -it c stty size      # now matches the caller's terminal at startup

Re-enables the previously flaky podman exec case in test/system/450-interactive.bats, which this change makes deterministic.

Checklist

Does this PR introduce a user-facing change?

exec: the requested console size is now applied when the exec terminal is created, so a process that reads its window size at startup (e.g. stty size) sees the correct value.

The exec API accepts a ConsoleSize but it is dropped: the exec
pseudo-terminal is created at its default size and only corrected
afterwards by an asynchronous resize. A short-lived exec that reads its
window size at startup (e.g. `stty size`) can therefore observe the wrong
size, because the resize may arrive after the process has already read it.
docker applies the size at creation.

Carry the requested ConsoleSize through ExecConfig and into the exec OCI
process spec (process.consoleSize) so the runtime sizes the terminal
before the process starts, removing the race. The local and remote CLIs
capture the caller's terminal size when -t is given and pass it through
ExecOptions, matching the behavior of `podman run`.

Re-enable the previously flaky `podman exec` case in the interactive
system test, which this change makes deterministic.

Signed-off-by: Shuai Yuan <shuaiyuanzju@gmail.com>
@github-actions github-actions Bot added the kind/api-change Change to remote API; merits scrutiny label Jun 18, 2026
@mheon

mheon commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

LGTM

Comment on lines +79 to +83
if [[ "$output" =~ stty ]]; then
echo "# stty flaked, retrying: $output" >&3
sleep 1
run_podman exec -it mystty stty size <$PODMAN_TEST_PTY
fi

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a flake retry here? If you claim this is race free than we should test that it is and never flakes, this will hide a flake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/api-change Change to remote API; merits scrutiny

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants