Skip to content

Run LMS stream processes in their own process group#1096

Open
stamateviorel wants to merge 1 commit into
micro-nova:mainfrom
stamateviorel:fix/lms-process-group-cleanup
Open

Run LMS stream processes in their own process group#1096
stamateviorel wants to merge 1 commit into
micro-nova:mainfrom
stamateviorel:fix/lms-process-group-cleanup

Conversation

@stamateviorel

Copy link
Copy Markdown

What does this change intend to accomplish?

LMS.disconnect() falls back to os.killpg(self.proc.pid, SIGKILL), but the spawned squeezelite/metadata processes were never made process-group leaders, so proc.pid is not a valid pgid — the killpg either fails or signals the parent's group. This starts both children with preexec_fn=os.setpgrp so each owns its own group, kills via os.killpg(os.getpgid(pid)), and tolerates ProcessLookupError when the process already exited (previously an exception escaped during stream teardown).

Running in production on our unit; stream stop/reassign no longer leaves orphaned squeezelite processes behind.

Checklist

  • Have you tested your changes and ensured they work? (in production on a real AmpliPi)
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • If applicable, have you updated the CHANGELOG?
  • Does your submission pass linting & tests? (python -m py_compile clean; happy to fix anything CI flags)

disconnect() falls back to os.killpg(self.proc.pid, SIGKILL), but the
spawned process was never made a process-group leader, so proc.pid is
not a valid pgid: the killpg either fails or signals the parent's whole
group. Start both squeezelite and the metadata reader with
preexec_fn=os.setpgrp so each owns its group, kill via
os.killpg(os.getpgid(pid)) on the real group, and tolerate
ProcessLookupError when the process already exited.

Signed-off-by: Stamate Viorel <stamate.viorel@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant