Skip to content

[feat] Add kill tree for sidecar #14360

Open

Description

@elibroftw

Describe the problem

My sidecar is a PyInstaller Python app. Because it's a single file how it works is a PyInstaller bootloader creates a child process for my app, and thus the "app" works. There are two issues right now.

  1. When I exit the Tauri app, the sidecar does not get killed.
  2. When I manually kill the child, its child process is still alive

Describe the solution you'd like

Well I'd rather just that the Tauri sidecar cleans up for me. However, if that's not possible, I'd like a kill_all method like there used to be?

Alternatives considered

struct MyStruct {
fn kill(&mut self) {
    if let Some(child) = self.child.take() {
           kill_process_tree(child.pid()).unwrap()
    }
  }
}


fn kill_process_tree(pid: u32) -> Result<(), String> {
    let mut system = System::new_all();
    system.refresh_all();

    let root_pid = Pid::from_u32(pid);
    let mut to_kill = HashSet::new();

    // Collect all descendant PIDs
    collect_descendants(&system, root_pid, &mut to_kill);
    to_kill.insert(root_pid);

    // Kill all processes (children first, then parent)
    for &pid in &to_kill {
        if let Some(process) = system.process(pid) {
            process.kill_with(Signal::Kill);
        }
    }

    Ok(())
}

fn collect_descendants(system: &System, pid: Pid, descendants: &mut HashSet<Pid>) {
    for (child_pid, process) in system.processes() {
        if let Some(parent_pid) = process.parent() {
            if parent_pid == pid {
                descendants.insert(*child_pid);
                collect_descendants(system, *child_pid, descendants);
            }
        }
    }
}

Additional context

No response

Activity

  1. changed the title [-][feat] Add kill tree[/-] [+][feat] Add kill tree for side car[/+] on Oct 25, 2025
  2. changed the title [-][feat] Add kill tree for side car[/-] [+][feat] Add kill tree for sidecar[/+] on Oct 25, 2025
  3. FabianLars commented on Oct 25, 2025

    @FabianLars
    Member
  4. sakina1303 commented on Nov 10, 2025

    @sakina1303
    Contributor

    i'd love to work on this and come up with a soluion!

  5. FabianLars commented on Sep 19, 2026

    @FabianLars
    Member

    Note that the PR that closed this only solves this for dev. In a bundled apps the sidecar behavior is still unchanged but there's a PR linked to the plugins-workspace issue I shared above.

  6. FabianLars commented on Oct 14, 2026

    @FabianLars
    Member

    The PR was reverted for v2. v3 alpha contains it. I think the kill tree portion could be re-added to v2 though 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions