Repository navigation
fix(macos): prevent zombie children from that_detached - #130
Merged
Merged
Conversation
On macOS /usr/bin/open already detaches via LaunchServices. spawn_detached() adds another fork and leaves zombie children. Align that_detached with with_detached (PR Byron#119). Co-authored-by: Cursor <cursoragent@cursor.com>
Byron
force-pushed
the
fix/macos-that-detached-zombies
branch
from
August 24, 2026 09:01
25f7a7c to
351bb54
Compare
Owner
|
Thanks a lot! I could validate that the test catches the problem, and that the fix works. |
Owner
|
And here it is: https://github.com/Byron/open-rs/releases/tag/v5.4.2 |
This was referenced Sep 1, 2026
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.
Problem
On macOS,
that_detached()still usesspawn_detached(), which extra-forks and_exit(0)s withoutwaitpid. The intermediate child becomes a zombie (Z/<defunct>).This is the same class of bug as #119, but #119 only changed
with_detached(). The default-open path (that_detached) was left on the old double-fork./usr/bin/openalready detaches via LaunchServices (LSOpenCFURLRef/NSWorkspace). The launched app is not a child of the caller. Extrafork+setsidis unnecessary on macOS and is what produces the zombies.Reproducer
Seen in a long-lived Tauri app: each URL open left a zombie. After many opens the process table filled with defunct
/usr/bin/openchildren.Tracked from the consumer side: tauri-apps/plugins-workspace#3544
(
tauri-plugin-openercallsopen::that_detached()whenwithisNone.)Why a bump of 5.3.4 / 5.4.1 is not enough
5.3.4+)with_detached()/usr/bin/open(.status())that_detached()spawn_detached()β zombiesVerified locally against
open 5.4.1: callingthat_detached("https://example.com")five times left 5 zombie children. After this patch: 0.Fix
Mirror
with_detached():that_detached()βthat()(wait for/usr/bin/opento return). The opened app still outlives the caller because LaunchServices owns it.spawn_detached()so launchers that stay attached (e.g. somexdg-opensetups) do not die with the parent (tauri-apps/tauri#6849).Tests
macos::tests::that_detached_does_not_leave_zombie_childrenopenshttps://example.comseveral times and asserts the parentβs zombie child count does not increase.Local:
cargo testandcargo clippy -- -D warningspass on macOS.Note on #6849
Waiting for
/usr/bin/opendoes not re-bind the launched app as a child. SIGKILL of the caller afteropenreturns leaves TextEdit / the browser running. Confirmed locally and on GitHub Actionsmacos-14/macos-15.Made with Cursor