tauri-apps / nsis-tauri-utils

A collection of NSIS plugins written in rust.
Apache License 2.0
16 stars 8 forks source link

When using KillProcess or KillProcessCurrentUser to close the tauri application during uninstallation, the tauri application cannot perform pre exit processing #39

Open Aostas opened 1 month ago

Aostas commented 1 month ago

KillProcess or KillProcessCurrentUser will call TerminateProcess, which will force the process to terminate and the process will not receive any signals. My Tauri application needs to perform some cleaning and closing child processes before terminate, which can result in orphan processes and occupy files in the application directory, leading to uninstallation and reinstallation exceptions. I tried to change TerminateProcess to GenerateConsoleCtrlEvent and replace nsis-tauri-utils.dll, but Tauri detects the hash value of the file and corrects it during build, so I cannot confirm if GenerateConsoleCtrlEvent will work.

Aostas commented 1 month ago

GenerateConsoleCtrlEvent does not work,But I found a solution. Just call taskkill.exe /PID {pid} /F /T. taskkill.exe /PID {pid} /F is equivalent to TerminateProcess, and the Process::kill function in the sysinfo crate is also implemented with this. Add /T(tree kill) to close all child processes and solve the issue.