Skip to content

Fix tart exec -t crash when stdout is not a terminal - #1378

Open
LittleYier wants to merge 1 commit into
openai:mainfrom
LittleYier:fix/exec-tty-without-terminal-stdout
Open

LittleYier wants to merge 1 commit into
openai:mainfrom
LittleYier:fix/exec-tty-without-terminal-stdout

Conversation

@LittleYier

Copy link
Copy Markdown
Contributor

tart exec -t crashes before the command starts if stdout is redirected or piped (like tart exec -t vm cmd | tee log), because Term.GetSize() reads from stdout and both the initial size and the SIGWINCH handler use try!. With -it it 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.

"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.
Copilot AI balanced review requested due to automatic review settings October 18, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T09:37:27.012653Z 6d7c2d6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

This branch has not been deployed

No deployments
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.

2 participants