Skip to content

feat(shell): add process group spawn option (fix #1332)#3351

Open
rterence wants to merge 2 commits intotauri-apps:v2from
rterence:feat/shell-process-group
Open

feat(shell): add process group spawn option (fix #1332)#3351
rterence wants to merge 2 commits intotauri-apps:v2from
rterence:feat/shell-process-group

Conversation

@rterence
Copy link
Copy Markdown

@rterence rterence commented Mar 19, 2026

Summary

  • Adds a processGroup boolean option to the shell plugin's spawn command
  • When enabled, spawns the child in a new process group (POSIX) or job object (Windows) using the process-wrap crate
  • Killing the child process now kills the entire process tree, fixing orphaned grandchild processes (e.g. PyInstaller-wrapped apps)

Closes #1332
cc. @FabianLars

Changes

  • Rust (process/mod.rs): Command::set_process_group() builder method, GroupChild type with platform-specific kill (Unix: killpg, Windows: job object termination via process-wrap)
  • Rust (commands.rs): processGroup field on CommandOptions, plumbed through prepare_cmd
  • TypeScript (index.ts): processGroup?: boolean on SpawnOptions
  • Dependencies: process-wrap 8.2 (std feature), libc 0.2 (unix)

Testing

  • All 12 unit tests pass, including 5 new process group tests
  • PyInstaller simulation tests reproduce the exact issue scenario: without processGroup killing the wrapper orphans the grandchild; with processGroup killing the wrapper also kills the grandchild
  • Windows not tested locally (uses process-wrap JobObject with polling try_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):

  1. The demo app is spawned with "Process Group" unchecked
  2. The kill button is pressed
  3. Activity Monitor shows the demo_app processes persist — the grandchild is orphaned

Second half — with processGroup enabled (the fix):

  1. The demo app is spawned with "Process Group" checked
  2. The kill button is pressed
  3. Activity Monitor shows all demo_app processes are terminated
process-group-demo.mp4

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
@rterence rterence requested a review from a team as a code owner March 19, 2026 17:04
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.

[shell] Add option to spawn command in process group

1 participant