Repository navigation
Fix tart exec -t crash when stdout is not a terminal - #1378
LittleYier wants to merge 1 commit into
Conversation
"tart exec -t" read the terminal size from stdout with try!, so redirecting or piping the output (e.g. "tart exec -t vm cmd | tee log") crashed with "failed to get terminal size: Inappropriate ioctl for device". Skip the initial size and resize events when the size is unavailable.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d7c2d61a7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| $0.interactive = interactive | ||
| $0.tty = tty | ||
| if tty { | ||
| if tty, let (width, height) = try? Term.GetSize() { |
There was a problem hiding this comment.
Read PTY dimensions from an attached terminal
When stdout is piped but stdin is still attached to the terminal (for example, tart exec -it vm bash | tee log), Term.GetSize() probes only STDOUT_FILENO in Term.swift:52, so this new try? always omits the initial terminalSize, and the analogous SIGWINCH handler omits every resize update as well. The remote PTY therefore runs with default or stale dimensions, causing wrapping and full-screen terminal programs to render incorrectly; fall back to the attached stdin or /dev/tty rather than dropping sizing.
Useful? React with 👍 / 👎.
tart exec -tcrashes before the command starts if stdout is redirected or piped (liketart exec -t vm cmd | tee log), becauseTerm.GetSize()reads from stdout and both the initial size and the SIGWINCH handler usetry!. With-itit also leaves the terminal in raw mode.Now the size is only sent when it can be read, and resize events without one are skipped.