Repository navigation
Fix zombie host after BEAM exit on single-instance packs - #19
Merged
Merged
Conversation
Clean prepare_quit now exits the host, unexpected exits respawn (with liveness and activate safety nets), so a dead BEAM cannot keep the single-instance lock forever.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
Bugbot Autofix is ON, but it could not run because on-demand usage is turned off. To enable Bugbot Autofix, turn on on-demand usage and set a spend limit in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 40437c7. Configure here.
Guard Win/Linux/macOS exit handlers against a replacement child, and kill children with pgrep -P so macOS e2e can exercise the host. Co-authored-by: Cursor <cursoragent@cursor.com>
Clear suppressTerminate before NSApp.terminate, and treat Linux zombie children as dead so respawn/activate can reclaim them. Co-authored-by: Cursor <cursoragent@cursor.com>
Arm quit on prepare_quit, exit(0) on macOS clean BEAM death, keep liveness watching after arming, and detect host death via OS pid. Co-authored-by: Cursor <cursoragent@cursor.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
system.prepare_quit/ host quit now terminates the host so the single-instance lock is released.instance.activateimmediate respawn when the child is dead.Test plan
mix test test/e2e/restart_test.exs test/e2e/instance_test.exs --include e2eon Windows (10 passed)Note
Medium Risk
Touches core process-lifetime and single-instance locking across all native hosts; incorrect quit vs crash classification could cause unwanted respawns or failed relaunches.
Overview
Fixes zombie single-instance hosts after BEAM dies or quits: clean shutdown now exits the native host so the lock is released, while crash/restart behavior stays on the unexpected-exit path.
On macOS, Linux, and Windows
HostController,system.prepare_quitopens a ~3s clean-exit window (no permanent “do not respawn”). If BEAM exits during that window or the host is quitting, the host terminates instead of respawning. A periodic liveness check runs the same exit handler when OS child-watch notifications are missed.instance.activate(and Windows control-pipe handling) can cancel backoff and spawn BEAM immediately when the child is dead butrestart_beamis on; Windows replies on the pipe before activate and uses PostMessage so second launches do not deadlock.Specs bump to v0.2.0 with new YAML cases; E2E covers runtime BEAM kill → respawn, prepare_quit → host exit, and activate → respawn, plus
BeamFixturestay_up / kill_direct_children! helpers.Reviewed by Cursor Bugbot for commit 40437c7. Configure here.