Skip to content

Add graceful Ctrl+C shutdown: clean up worktrees on interrupt#83

Merged
that-github-user merged 1 commit intomainfrom
issue-60-ctrl-c-cleanup
Mar 28, 2026
Merged

Add graceful Ctrl+C shutdown: clean up worktrees on interrupt#83
that-github-user merged 1 commit intomainfrom
issue-60-ctrl-c-cleanup

Conversation

@that-github-user
Copy link
Copy Markdown
Owner

Summary

  • SIGINT handler registered before worktree creation loop
  • On Ctrl+C: cleans up all worktrees, prunes branches, exits with code 130
  • Handler deregistered after normal run completion
  • Prevents worktree leaks on user interrupts

Generated by thinktank — 5 agents, Agent #5 recommended (only agent passing tests, +14/-1, single file).

Change type

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • CI / infrastructure
  • Chore

Related issue

Closes #60

How to test

  1. Run thinktank run "some task" -n 3
  2. Press Ctrl+C mid-run
  3. Verify "Interrupted — cleaning up worktrees..." message
  4. Verify no leftover worktrees in temp directory

Breaking changes

  • This PR introduces breaking changes

🤖 Generated with thinktank + Claude Code

Register SIGINT handler before worktree creation that cleans up all
worktrees and branches on Ctrl+C, then exits with code 130. Handler
is deregistered after normal run completion.

Generated by thinktank (5 agents, Agent #5 recommended — only agent
passing tests, +14/-1, focused single-file change).

Closes #60

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@that-github-user
Copy link
Copy Markdown
Owner Author

Self-review (dogfooding): Agent #5 was the only one of 5 that passed tests — took the simplest approach (14 lines, 1 file). Agents 2-4 clustered at 53% similarity but all failed. Exit code 130 is standard for SIGINT. 64 tests pass, lint clean.

@that-github-user that-github-user merged commit 0be06c1 into main Mar 28, 2026
@that-github-user that-github-user deleted the issue-60-ctrl-c-cleanup branch March 28, 2026 18: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.

Graceful Ctrl+C shutdown: clean up worktrees on interrupt

1 participant