Skip to content

feat(guest): add PTY allocation and window resize for StartProcess - #107

Closed
Tomer Glottmann (tomergee) wants to merge 1 commit into
mainfrom
feat/guest-pty-resize-104
Closed

Tomer Glottmann (tomergee) wants to merge 1 commit into
mainfrom
feat/guest-pty-resize-104

Conversation

@tomergee

Copy link
Copy Markdown
Collaborator

Fixes #104.

Summary

  • Extend ateenv.v1alpha.ProcessService in proto/ateenv/v1alpha/guest.proto with TTY (rows, cols) on StartProcessRequest and ResizeProcess(ResizeProcessRequest).
  • Regenerate Go and Python protobuf/gRPC bindings (proto/ateenv/v1alpha/guest*.pb.go and clients/python/src/ate_env/_gen/ateenv/v1alpha/guest_pb2*).
  • Implement Linux PTY master/slave allocation (/dev/ptmx, TIOCGPTPEER, TIOCSWINSZ) in guest/process/pty_linux.go and wire controlling-terminal setup (Setsid: true, Setctty: true, Ctty: 0) in guest/process/tracker.go.
  • Merge stdout and stderr onto the stdout spool when tty is set, exempting PTY output from MaxLogBytes truncation and treating EIO on the master fd as clean EOF.
  • Forward ResizeProcess in internal/apiservice/server.go and expose (*Process).Resize(ctx, rows, cols) in clients/go/process.go.

Verification

  • Added unit and integration tests in guest/process/service_test.go (TestTTYControllingTerminalAndMergedOutput, TestTTYResizeAndSIGWINCH, TestTTYInputAndCloseEOT, TestTTYExemptFromLogCap) and clients/go/client_test.go (TestProcessTTYAndResize).
  • Ran go test -race ./..., go vet ./..., make verify-gofmt, make verify-boilerplate, and pytest clients/python/tests.

@rakyll

Copy link
Copy Markdown
Collaborator

What's the use case for resizing the window?

@anzal1

Copy link
Copy Markdown

Jaana Dogan (@rakyll) I proposed this in #104, so jumping in on tomergee's PR: it's for full-screen programs in an interactive session (vim, less, top). They lay out to the pty's size, so when the user resizes their local terminal they need the new rows and cols, or they keep drawing at the old size and lines wrap or get clipped. ssh and kubectl exec forward resizes for the same reason. SignalProcess can already send SIGNAL_WINCH, but it carries no size, so ResizeProcess sets the pty size (TIOCSWINSZ) and the kernel sends SIGWINCH to the process itself.

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.

Guest protocol: tty and window resize for StartProcess

3 participants