Always exit the phone on Ctrl-C #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/ctrl-c-shutdown"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On macOS, Ctrl-C sometimes printed
shutting downand then hung indefinitely, with further Ctrl-C presses doing nothing.Why
_main()installs a SIGINT/SIGTERM handler vialoop.add_signal_handler, which permanently replaces Python's default Ctrl-C behaviour. If the graceful shutdown stalls anywhere — most plausibly PortAudio wedging while closing an audio stream on macOS — a second Ctrl-C is swallowed too, leaving no way to quit. That matches the observed hang.(The exact stall is a flaky macOS CoreAudio/PortAudio condition I couldn't reproduce deterministically; this fixes the structural cause — an unbounded, un-interruptible shutdown — rather than the device quirk.)
Change
app.stop()with a 5s timeout; past it,os._exit(0)so a single Ctrl-C always terminates.Verified the normal (non-stalled) shutdown still exits cleanly via a PTY harness across idle, ringing, and two-connected-nodes scenarios.
🤖 Generated with Claude Code
7da11405a6to2a22e4b133