Repository navigation
fix: SIGTERM stops the audio player instead of orphaning it - #22
Merged
Merged
Conversation
Python's default SIGTERM exits on the spot, with no cleanup. A headless mpv (--idle, driven over IPC) then plays out the queued chunk and idles forever. Under flatpak, mpv also sits in its own process group (bwrap moves it), so a caller's `kill -- -PGID` can't reach it either: TTS_ka is the only thing that can stop it. main() now turns SIGTERM into Terminated, a KeyboardInterrupt subclass, so it takes the existing Ctrl+C path (stop_active_streaming_player) and exits 143. A SIGTERM that the parent set to SIG_IGN stays ignored. Found through a Claude Code Stop hook that interrupts the previous turn with `kill -- -PGID`: each interrupted turn left an mpv running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sending
kill(SIGTERM) totts-kamid-stream left mpv running. Python's default SIGTERM exits at once with no cleanup, so a headless mpv (--idle, driven over IPC) plays out its queued chunk and then idles forever. With a flatpak mpv,bwrapalso moves mpv into its own process group, so evenkill -- -PGIDon the caller's group doesn't reach it. TTS_ka is the only thing that can stop it.main()now turns SIGTERM intoTerminated, aKeyboardInterruptsubclass, so it takes the existing Ctrl+C path (stop_active_streaming_player) and exits 143. If the parent process set SIGTERM to be ignored, it stays ignored.The bug showed up in a Claude Code Stop hook that speaks each turn and interrupts the previous turn with
kill -- -PGID: every interrupted turn left an mpv behind.Test plan
--live), and an ignored SIGTERM stays ignored. Without the fix, the SIGTERM kills pytest itself.conftestfixture restores the SIGTERM handler, somain()can't leave it installed in pytest.pytestsuite passestts-ka -s --no-guiwith a flatpak mpv, SIGTERM to the group mid-playback → mpv exits (before the fix it kept running)🤖 Generated with Claude Code