Skip to content

fix(skills/bounding-heavy-commands): stop a joined line of bounded commands on one Ctrl-C - #71

Merged
sourcehawk merged 4 commits into
fix/budget-without-file-cachefrom
fix/one-ctrl-c-stops-a-joined-line
Sep 30, 2026
Merged

sourcehawk merged 4 commits into
fix/budget-without-file-cachefrom
fix/one-ctrl-c-stops-a-joined-line

Conversation

@sourcehawk

@sourcehawk sourcehawk commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Description

Fixes #69

One Ctrl-C did not stop a line of joined wrapper calls, such as the measurement line of #63. The wrapper caught the signal, cleaned up, and exited normally with 130, so the shell started the next call and the user had to press Ctrl-C once per command. After its cleanup and its output lines, a wrapper that received SIGINT, SIGTERM, SIGHUP, or SIGQUIT now restores the default handler and sends the signal to itself, so the shell sees a death by signal and stops the line. A --measure-rows run that had a failed row and is then stopped by a signal now ends by that signal (a shell reads 128+N) rather than with the failed row's exit code.

Changes

  • The wrapper records the first stop signal that it receives: when it forwards one to the command, when one arrives anywhere in the list of --measure-rows outside a running row, and when SIGINT arrives during the queue wait. After cleanup it dies from that signal. For SIGQUIT the core-file limit is set to 0 first.
  • A command that exits 130 by itself, with no signal reaching the wrapper, still gives a normal exit 130, and the line continues.
  • The --measure-rows row of the skill's option table now says that a stop signal ends the wrapper by that signal, so a Ctrl-C, which reaches the shell too, stops a joined line. A signal sent to the wrapper alone does not stop the shell's line.

Challenges

A test with sh proves nothing on systems where sh is dash: dash dies from a group SIGINT by itself, so the line stops even without the fix. The new tests use bash, which stops a line only when the running command dies from the signal, and they are skipped where bash is missing.

Related

Testing

TDD with process tests. Each runs bash -c '<wrapper call>; touch <file>' in its own process group and sends SIGINT to the group, as a terminal does. The cases: Ctrl-C while the command runs, Ctrl-C while the wrapper waits in the queue (a holder takes all the slots), and Ctrl-C during --measure-rows. In each, the line stops and the file is not created. Two guard tests cover existing behavior: a command that exits 130 by itself lets the line continue, and a signal sent to the wrapper alone gives the caller 130 or 143. The first three failed before the change, because the line continued. The existing process tests now expect death by signal. The full suite (312 tests) passes through the queue.

🤖 Generated with Claude Code

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 review overview

🟡 Changes recommended

Non-SIGINT signals can escape between measured rows, and the shell behavior is overstated in documentation.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Updates the bounded-command wrapper so Ctrl-C stops joined command lines after cleanup.

Changes:

  • Re-raises received stop signals after cleanup.
  • Adds joined-line and signal-status process tests.
  • Documents signal behavior for measured rows.
File Description
skills/​bounding-heavy-commands/​SKILL.md Documents measured-row signal handling.
skills/​bounding-heavy-commands/​scripts/​bounded_run.py Tracks signals and terminates accordingly.
skills/​bounding-heavy-commands/​scripts/​tests/​test_bounded_run.py Tests wrapper and joined-line signal behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread skills/bounding-heavy-commands/SKILL.md Resolved
Copilot AI balanced review requested due to automatic review settings September 30, 2026 08:50
@sourcehawk
sourcehawk force-pushed the fix/one-ctrl-c-stops-a-joined-line branch from 3cca79c to 414be42 Compare September 30, 2026 08:50
@sourcehawk

Copy link
Copy Markdown
Owner Author

Review round on 3cca79c (review 5363805257). No suppressed findings.

Comment gate, self-evaluated because this session could not dispatch an agent: this PR's code comments did not change. The comments in the rows loop and in main() belong to #63, and its round comment covers them.

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 review overview

🟡 Changes recommended

A new docstring overstates when signal termination stops a shell’s joined command line.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (3)

Copilot AI balanced review requested due to automatic review settings September 30, 2026 08:57
@sourcehawk
sourcehawk force-pushed the fix/one-ctrl-c-stops-a-joined-line branch from 414be42 to 910ee86 Compare September 30, 2026 08:57
@sourcehawk

Copy link
Copy Markdown
Owner Author

Review round on 414be42 (review 5363887031). No suppressed findings.

  • Document Ctrl-C terminal signal behavior in caller test: applied in 910ee86. This is text that users read (a docstring); it was corrected for accuracy, and it grew by the condition.

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 review overview

🟢 Approval recommended

The signal handling is consistent across execution paths and is covered by focused process tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:06
@sourcehawk
sourcehawk force-pushed the fix/one-ctrl-c-stops-a-joined-line branch from 910ee86 to c408db0 Compare September 30, 2026 09:06

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 review overview

🟡 Changes recommended

The documented failed-row-then-signal behavior lacks a process-level regression test.

Review effort: Balanced
Findings: 1 Low severity

Open (1)

Copilot AI balanced review requested due to automatic review settings September 30, 2026 09:15
@sourcehawk
sourcehawk force-pushed the fix/one-ctrl-c-stops-a-joined-line branch from c408db0 to 7c6f96d Compare September 30, 2026 09:15
@sourcehawk

Copy link
Copy Markdown
Owner Author

Review round on c408db0 (review 5364081988). No suppressed findings.

  • Add process-boundary test for failed-row SIGINT precedence: added in 6656283.

Comment gate: no code comment changed.

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 review overview

🟢 Approval recommended

The implementation handles cleanup and signal termination consistently, with comprehensive process-level regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

A line of wrapper calls joined with ';' needed one Ctrl-C for each call. The wrapper caught the signal, cleaned up, and exited normally with 130, so the shell ran the next call.

When a stop signal (SIGINT, SIGTERM, SIGHUP, SIGQUIT) reaches the wrapper, while it waits in the queue or while the command runs, the wrapper now finishes its cleanup and its lines, restores the default handler, and sends the signal to itself. The shell sees a death by signal and stops the line. A caller that reads the status still reads 128 plus the signal. A command that exits 130 by itself, with no signal to the wrapper, still gives a normal exit 130. --measure-rows still stops its rows first. The --inside-cap process is unchanged: its parent wrapper got the signal and ends by it.

Fixes #69

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sourcehawk and others added 3 commits September 30, 2026 11:22
… a Ctrl-C, not on a signal to the wrapper alone

The shell stops a line of joined commands when it gets the interrupt too, as with a Ctrl-C at the terminal. A signal sent to the wrapper alone ends the wrapper by that signal, and the shell runs the next command of the line. The usage text and the skill said that each stop signal to the wrapper stops the line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ust get the signal too

The docstring said that a shell stops a joined line when the running command dies from a signal. The shell stops it only when it got the signal as well, as with a Ctrl-C at the terminal; the caller test shows bash going on when only the wrapper is signalled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter a failed row

No process test covered the case where a row fails and a later row gets the interrupt. The new test runs --measure-rows in a bash line, lets the first row exit 3, interrupts the second, and checks that the wrapper dies from SIGINT and that the next command of the line does not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcehawk
sourcehawk force-pushed the fix/one-ctrl-c-stops-a-joined-line branch from 7c6f96d to 1955b7c Compare September 30, 2026 10:22
@sourcehawk
sourcehawk merged commit e4baec9 into main Sep 30, 2026
10 checks passed
@sourcehawk
sourcehawk deleted the fix/one-ctrl-c-stops-a-joined-line branch September 30, 2026 10:23
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.

One Ctrl-C does not stop a line of joined bounded commands

2 participants