Open Aostas opened 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.
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.