Skip to content

ctr: make exec pty behavior consistent with run#5527

Merged
estesp merged 2 commits intocontainerd:masterfrom
samuelkarp:freebsd-ctr-exec
May 25, 2021
Merged

ctr: make exec pty behavior consistent with run#5527
estesp merged 2 commits intocontainerd:masterfrom
samuelkarp:freebsd-ctr-exec

Conversation

@samuelkarp
Copy link
Copy Markdown
Member

This series adjusts the pty behavior in ctr task exec to be consistent with ctr run. Two changes are made:

  1. The console.Console is found prior to task.Exec and used as with cio.WithStreams
  2. Initial pty resize and signal handling is moved after task.Start

Both of these changes seem necessary on FreeBSD with runj; without change 1 keyboard input did not seem to be correctly sent to the shim and without change 2 the initial resize was lost.

I also tested these changes on Linux and ctr task exec seemed to continue to work fine both before and after these commits. I do not currently have access to a Windows machine to test any behavioral differences there.

Use cio.WithStreams with explicit console device when --tty is passed,
consistent with how ctr run behaves.

Signed-off-by: Samuel Karp <[email protected]>
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented May 23, 2021

Build succeeded.

Comment thread cmd/ctr/commands/tasks/exec.go Outdated
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.

The following check in this if block is not needed because tty is always false here.

			if tty {
				return errors.New("can't use log-uri with tty")
			}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that! I've restructured the logic here to make it more clear as to which cases are which, though it now does look a bit different from ctr run (which doesn't have the same error checks).

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.

Thanks for fixing this!

Handle initial pty resize after the exec process has started and the pty
is available, consistent with the behavior of ctr run.

Signed-off-by: Samuel Karp <[email protected]>
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented May 25, 2021

Build succeeded.

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@estesp estesp merged commit 0a92694 into containerd:master May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants