Closed Sytten closed 1 year ago
The webkit processes are handled by the OS, so it can successfully close that, but sidecar is handled by the tauri app and if you force close the app, it means all code execution is interrupted immediately and the cleanup code won't have a chance to run its logic, nothing we can do about this.
I get that, but is there a best practice to handle that? Users somethings force kill applications. I guess the Sidecar process could monitor for it's parent somehow, but I appreciate any suggestion on that.
Nothing off the top of my head. kill -9
should be used carefully https://medium.com/naukri-engineering/use-of-kill-kill-9-naukri-engineering-5f01c4ff31ea
Agreed but I would expect to have a solution for the MacOS Force Quit menu. It should send a SIGTERM, but our testing shows that it might not or at least it is not handled properly. For example, I tried to force quit VSCode and all the LSP servers (rust-analyzer) were also killed so clearly there is a way to handle it without leaving children process alive.
We are not doing anything special tbh, we are merely using the normal Rust Command
and I couldn't find a reliable way to ensure there is no zombie processes.
Yeah I did look a lot into it and I found what VSCode does. It's basically polling for the parent PID and cleaning the resources when it detects the parent was killed. I am trying to reproduce the same behaviour in rust. https://github.com/microsoft/vscode/blob/14459d6db1a088fbf1c631350cb27ade59fe1e39/src/bootstrap-fork.js#L226
For those that might find this thread later, I built a simple crate (https://github.com/caido/process_alive) to verify if a certain process is alive. I then pass the tauri PID to the child process on start and the child starts monitoring the parent status in a thread every 5s and kills itself if the parent is dead.
Describe the bug
From our experience, the sidecars are killed properly without any code on Linux and MacOs (not Windows) without any code. To fix the issue on Windows, we added code to kill the sidecar on
RunEvent::ExitRequested
. While it fixed the issue for Windows, we found that if the app is force killed with akill -9
orForce Quit
on Mac, it will not kill the sidecar properly. What is interesting is that the webkit processes are killed properly so I am unsure why the sidecar isn't.Reproduction
Expected behavior
The sidecar should be killed alongside the application
Platform and versions
We use a forked version of tauri but our changes are not related to this.
Stack trace
No response
Additional context
No response