feat(shell): add process group spawn option (fix #1332)#3351
Open
rterence wants to merge 2 commits intotauri-apps:v2from
Open
feat(shell): add process group spawn option (fix #1332)#3351rterence wants to merge 2 commits intotauri-apps:v2from
rterence wants to merge 2 commits intotauri-apps:v2from
Conversation
Add a `processGroup` boolean option to the shell plugin's spawn command. When enabled, the child process is spawned in its own process group (POSIX) or job object (Windows) using the `process-wrap` crate, so that killing the child also kills the entire process tree. This fixes the issue where programs like PyInstaller wrappers spawn a child process that gets orphaned when Tauri kills the parent.
Add end-to-end tests that reproduce the exact scenario from issue tauri-apps#1332: a wrapper process (like PyInstaller's bootloader) spawns a grandchild. - Without process_group: killing the wrapper orphans the grandchild - With process_group: killing the wrapper also kills the grandchild
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
processGroupboolean option to the shell plugin'sspawncommandprocess-wrapcrateCloses #1332
cc. @FabianLars
Changes
process/mod.rs):Command::set_process_group()builder method,GroupChildtype with platform-specific kill (Unix:killpg, Windows: job object termination viaprocess-wrap)commands.rs):processGroupfield onCommandOptions, plumbed throughprepare_cmdindex.ts):processGroup?: booleanonSpawnOptionsprocess-wrap8.2 (std feature),libc0.2 (unix)Testing
processGroupkilling the wrapper orphans the grandchild; withprocessGroupkilling the wrapper also kills the grandchildprocess-wrapJobObjectwith pollingtry_wait)Demo
The video below demonstrates the fix using a real PyInstaller-bundled Python app spawned from the Tauri example app's Shell view.
First half — without
processGroup(the bug):demo_appprocesses persist — the grandchild is orphanedSecond half — with
processGroupenabled (the fix):demo_appprocesses are terminatedprocess-group-demo.mp4