Skip to content

fix(desktop): kill zombie child processes on app quit#346

Merged
alchemistklk merged 1 commit intomainfrom
fix/desktop-zombie-processes
Mar 22, 2026
Merged

fix(desktop): kill zombie child processes on app quit#346
alchemistklk merged 1 commit intomainfrom
fix/desktop-zombie-processes

Conversation

@alchemistklk
Copy link
Copy Markdown
Contributor

@alchemistklk alchemistklk commented Mar 22, 2026

Relates to #510

Summary

  • Await orchestrator.dispose() in before-quit — previously fire-and-forget (void), Electron exited before child processes were killed, leaving orphans that blocked app deletion ("The application Nexu is not open anymore")
  • Escalate to SIGKILL after SIGTERM timeoutstopUnit() sent SIGTERM twice (ignorable); now sends SIGTERM → waits 3s → SIGKILL → 5s final deadline
  • No new dependencies

Test plan

  • Build desktop app (pnpm dist:mac:unsigned)
  • Launch app, verify controller + web start normally
  • Quit app (Cmd+Q), then verify no orphan Nexu processes remain (ps aux | grep Nexu)
  • Delete /Applications/Nexu.app from Finder — should succeed without "item is in use" error
  • Force-quit scenario: kill main window, verify child processes are cleaned up

🤖 Generated with Claude Code

The before-quit handler was fire-and-forget (void orchestrator.dispose()),
so Electron exited before child processes were terminated. Additionally,
stopUnit() only sent SIGTERM twice without escalating to SIGKILL, allowing
processes to ignore shutdown and become orphans that block app deletion.

- Await orchestrator.dispose() by blocking quit with event.preventDefault()
- Escalate to SIGKILL after 3s if SIGTERM is ignored
- Add 5s final deadline to prevent hanging quit
@alchemistklk
Copy link
Copy Markdown
Contributor Author

/cr

@slack-code-review-channel
Copy link
Copy Markdown

✅ CR topic created in Feishu topic group Refly CR.

@alchemistklk alchemistklk merged commit b699c35 into main Mar 22, 2026
6 checks passed
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.

2 participants