Skip to content

fix(runner): release the file teardown when Ctrl-C stops the run - #1332

Merged
Chemaclass merged 1 commit into
mainfrom
fix/1323-ctrl-c-skips-tear-down-after-script
Aug 19, 2026
Merged

fix(runner): release the file teardown when Ctrl-C stops the run#1332
Chemaclass merged 1 commit into
mainfrom
fix/1323-ctrl-c-skips-tear-down-after-script

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1323

Ctrl-C killed the children, swept the temp dirs and exited without running the interrupted file's tear_down_after_script. The per-test tear_down already survived, through the test subshell's EXIT trap, so the two halves of the pair behaved differently for one signal.

💡 Changes

  • Settle the pending file teardown from the handler, reusing the debt --stop-on-failure skips tear_down_after_script in sequential runs #1321 introduced. After the kill, so the per-test hook still goes first as in a normal run; before the temp-file sweep, so a hook reading a bashunit::temp_file still finds it.
  • Reset SIGINT to its default disposition first. The hook is user code and may never return, and a handler that cannot be interrupted would leave no way out but SIGKILL. Checked by hand with a hook sleeping 60s: a second Ctrl-C ends the run in about 2s.
  • Covered by a unit test of the handler body. An acceptance test that signalled a real run failed 2 runs in 3 under a loaded --parallel suite, since delivery depends on job control and on which frame the shell is in when the signal lands.
  • --parallel is untouched and still runs neither teardown on Ctrl-C. The parent cannot fix that, because several files are in flight and each file's hook is redefined as the loop advances. Filed as Ctrl-C runs neither teardown under --parallel #1331.

Ctrl-C killed the children, swept the temp dirs and exited without running
the interrupted file's tear_down_after_script, so a file-scoped resource
was leaked. The per-test tear_down already survived, through the test
subshell's EXIT trap, which made the two halves of the pair behave
differently for one signal.

Settle the pending file teardown from the handler, reusing the debt #1321
introduced: after the kill, so the per-test hook still goes first as it
does in a normal run, and before the temp-file sweep, so a hook reading a
bashunit::temp_file still finds it.

Reset SIGINT to its default disposition first. The hook is user code and
may never return, and a handler that cannot itself be interrupted would
leave no way out but SIGKILL. Verified by hand with a hook sleeping 60s:
a second group-delivered Ctrl-C ends the run in ~2s.

Covered by a unit test of the handler body rather than by signalling a
real run. An acceptance test that did the latter failed 2 runs in 3 under
a loaded --parallel suite, because delivery depends on job control and on
which frame the shell is in when the signal lands.

--parallel is untouched and still runs neither teardown on Ctrl-C. The
parent cannot fix that: several files are in flight and each file's hook
is redefined as the loop advances. Filed as #1331.

Closes #1323
@Chemaclass Chemaclass added the bug Something isn't working label Aug 19, 2026
@Chemaclass Chemaclass self-assigned this Aug 19, 2026
@Chemaclass
Chemaclass merged commit 9ae5fba into main Aug 19, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/1323-ctrl-c-skips-tear-down-after-script branch August 19, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant