Skip to content

Commit d9731e6

Browse files
committed
cancel button now kills processes
1 parent acc639a commit d9731e6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/core/package_manager.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,24 @@ void PackageManager::cancelRunningOperation() {
193193
Logger::warning("Cancelling running operation...");
194194
emit operationOutput("\n>>> Operation cancelled by user <<<\n");
195195

196-
// First try to terminate gracefully
196+
// When using pkexec, we need to kill the actual pacman/yay/paru process
197+
// not just the pkexec wrapper. Use pkill to terminate all package manager processes.
198+
QProcess killProcess;
199+
killProcess.start("pkexec", QStringList() << "bash" << "-c"
200+
<< "pkill -TERM pacman; pkill -TERM yay; pkill -TERM paru");
201+
killProcess.waitForFinished(2000);
202+
203+
// Also terminate the QProcess wrapper
197204
m_process->terminate();
198205

199-
// Wait up to 5 seconds for graceful termination
200-
if (!m_process->waitForFinished(5000)) {
201-
// If it doesn't terminate gracefully, force kill
206+
// Wait up to 3 seconds for graceful termination
207+
if (!m_process->waitForFinished(3000)) {
208+
// Force kill if still running
202209
Logger::warning("Process did not terminate gracefully, forcing kill...");
210+
killProcess.start("pkexec", QStringList() << "bash" << "-c"
211+
<< "pkill -KILL pacman; pkill -KILL yay; pkill -KILL paru");
212+
killProcess.waitForFinished(2000);
213+
203214
m_process->kill();
204215
m_process->waitForFinished(1000);
205216
}

0 commit comments

Comments
 (0)