#Child process not exiting when main process exits

13 messages · Page 1 of 1 (latest)

indigo mist
#

This is how i'm starting the process (nothing special):

let mut child = Command::new(...)
            .args(...)
            .current_dir(...)
            .spawn()?;
#

Might also be useful to know that i'm on Windows

tropic wagon
#

is the command's process not killed or just some child of that process?

To explain what i mean, pyinstaller in (single-file mode) spawns 2 process and on exit only one is killed (because pyinstaller can't clean up after itself apparently harold)

indigo mist
tropic wagon
#

okay then maybe both options. tor will spawn multiple processes too and i'm not sure if it cleans them all up 🤔
but one after another i guess.

tauri uses process.exit() to close the app which prevents Drop implementations from being executed. In other words, you have to manually kill the child in the Exit event. Or maybe try tauri's Command first, it should kill them automatically on exit.
https://docs.rs/tauri/latest/tauri/api/process/struct.Command.html

indigo mist
tropic wagon
#

not sure what you mean

indigo mist
#

tauri::api::process::Command doesn't exist

tropic wagon
#

it needs the process-command-api feature flag (which can only be enabled by enabling part of the "shell" allowlist in tauri.conf.json, otherwise tauri's cli will just remove the cargo feature flag again)

indigo mist
#

gotcha

#

this seems to work

appWindow.onCloseRequested(async () => {
  await invoke("disconnect");
});```
#

hm actually it doesn't work if i close the application by pressing ctrl + C but i doubt anything can be done about that