Skip to content

Sidecar binaries not cleaned up when using prevent_exit and AppHandle::exit #2464

@guillemcordoba

Description

@guillemcordoba

Describe the bug

Children processes are not cleaned up when using Event::ExitRequested's api.prevent_exit(), and invoking AppHandle::exit(0).

To Reproduce

Steps to reproduce the behavior:

  1. With a main.rs that looks like this and also launches sidecar binaries:
tauri::Builder::default()
    .system_tray(sys_tray)
    .on_system_tray_event(|app, event| {
      match event {
        SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
          "quit" => {
            app.exit(0);
          }
          _ => {}
        },
        _ => {}
      }
    })
    .build(tauri::generate_context!())
    .expect("Error building app")
    .run(|_app_handle, event| {
          if let Event::ExitRequested { api, .. } = event {
            api.prevent_exit();
          }
    });
  1. Run the tauri app.
  2. Execute the "quit" system tray item.
  3. See in the task administrator that the sidecar programs are still running.

Expected behavior

That the sidecar programs are shutdown when the api.exit(0); is executed

Platform and Versions (required):

Operating System - Windows, version 10.0.18363 X64
Webview2 - 92.0.902.73

Node.js environment
  Node.js - 14.17.3
  @tauri-apps/cli - 1.0.0-beta.7
  @tauri-apps/api - 1.0.0-beta.6

Global packages
  npm - 6.14.13
  yarn - 1.22.10

Rust environment
  rustc - 1.54.0
  cargo - 1.54.0

App directory structure
/.git
/.github
/node_modules
/public
/scripts
/src
/src-tauri
/tests

App
  tauri.rs - 1.0.0-beta.6
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - Set automatically by Vue CLI plugin
  devPath - Set automatically by Vue CLI plugin
  framework - Vue.js (Vue CLI)
  bundler - Webpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions