INNER CODE UNIT · Python
_signal_handler
Dicklesworthstone/claude_code_agent_farm · claude_code_agent_farm.py:720
def _signal_handler(self, sig: Any, frame: Any) -> None:
"""Handle shutdown signals gracefully with force-kill on double tap"""
current_time = time.time()
# Check if this is a SIGINT (Ctrl-C)
if sig == signal.SIGINT:
# Check for double tap
if self._last_sigint_time and (current_time - self._last_sigint_time) < self._force_kill_threshold:
# Second Ctrl-C within threshold - force kill
console.print("\n[red]Force killing tmux session...[/red]")
with contextlib.suppress(Exception):
run(f"tmux kill-session -t {self.session}", check=False, quiet=True)
# Clean up state files
try:
if hasattr(self, "state_file") and self.state_file.exists():
self.state_file.unlink()
lock_file = Path.home() / ".claude" / ".agent_farm_launch.lock"
if lock_file.exists():