Skip to content

Let Ctrl+C in the Stata pane stop a command Stata runs through shell - #447

Merged
jbearak merged 2 commits into
mainfrom
t3/a3d743aa
Nov 23, 2026
Merged

jbearak merged 2 commits into
mainfrom
t3/a3d743aa

Conversation

@jbearak

@jbearak jbearak commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Ctrl+C in the Stata pane didn't break a long-running command when Stata was running it through shell (or !). shell sleep 60 kept going until the sleep finished.

The sight-pty helper sent SIGINT only to Stata's pid. Stata waits for whatever its shell started, so nothing happened until that child ended. The helper now sends SIGINT to Stata's process group, as a terminal's ^C does. This matches what it already does for hang-up and kill. The Perch console (tty.js) uses the same helper, so it gets the fix too.

Proof:

  • Ran the editor console with real StataMP 18 on macOS.
    • Before the fix: Ctrl+C during shell sleep 60 did nothing.
    • After the fix: Stata returns to the prompt and runs the next command, and no sleep is left behind.
    • Ctrl+C still prints --Break-- for sleep 20000, a Mata loop, while 1 {}, and a loop that floods output.
  • A new helper test fails without the fix and passes with it.
  • Line endings, typecheck, lint, and bun test ./tests pass (10520 tests, 0 failures).

Not changed: the Bun PTY that the command-line sight console uses has a similar gap. Its Stata shares the console's own process group, so it needs a different fix.

Reviewed with sol-loop: 1 round with gpt-6.2-sol. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code (T3 Code).

Summary by CodeRabbit

  • Bug Fixes
    • Ctrl+C now interrupts Stata and commands it runs through shell or !, rather than only interrupting the directly launched command. This also helps foreground child processes respond to the interrupt.
  • Documentation
    • Clarified Ctrl+C behavior in the macOS and Linux console guides, including its effect on running commands and queued sends.

The sight-pty helper sent SIGINT to Stata's pid only. Stata waits for
what its shell runs, so Ctrl+C during `shell sleep 60` did nothing
until the sleep ended. Send it to the process group, as a terminal's
^C would, like the helper's hang-up and kill already do.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PTY helper now sends SIGINT to the command process group. An integration test checks interrupt behavior for a foreground child, and the console documentation describes Ctrl+C behavior for Stata and commands it runs through shell or !.

Changes: PTY interrupt handling

Layer / File(s) Summary
Process-group interrupt delivery
client/pty-helper/sight-pty.c, tests/integration/console/helper-pty.test.ts, docs/send-to-stata.md
The I control command sends SIGINT to the command process group. The integration test checks that the shell proceeds after its foreground child is interrupted. The documentation states that Ctrl+C interrupts Stata and commands it runs through shell or !.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • jbearak/sight#341: Introduces the sight-pty helper whose signal handling this change modifies.
Merge Risk: Minimal · up to daf8c

Ctrl+C in the Stata pane will now also interrupt commands Stata launched through shell or !. The change is small and tested, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main behavior change: Ctrl+C in the Stata pane now stops a command Stata runs through shell. The raw summary and objectives confirm the change sends SIGINT to the process group rat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main behavior change: Ctrl+C in the Stata pane now stops a command Stata runs through shell. The raw summary and objectives confirm the change sends SIGINT to the process group rather than only Stata's PID, which is what makes shell-launched commands stop. The title is specific and matches the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 3aef6af2-ed01-4ef9-b149-a0f0653fafd0
Commits

Reviewing files that changed from the base of the PR and between aa5af6e and daf8c5d.

Files selected for processing: 3

  • client/pty-helper/sight-pty.c
  • docs/send-to-stata.md
  • tests/integration/console/helper-pty.test.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

@jbearak
jbearak merged commit 86ad9f1 into main Nov 23, 2026
15 checks passed
@jbearak
jbearak deleted the t3/a3d743aa branch November 23, 2026 00:34
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.

1 participant