From 75d0b8403fe805b5fb34df3ae3e15b6fc8f34830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 7 Mar 2011 18:03:28 +0100 Subject: [PATCH] Add KAuth support to KWin process killer See http://svn.reviewboard.kde.org/r/4460/ Thanks to Mikael Gerdin for the patch. CCMAIL: mikael.gerdin@gmail.com FEATURE: 129476 FIXED-IN: 4.7.0 --- killer/killer.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/killer/killer.cpp b/killer/killer.cpp index 581c60c607..d37a654404 100644 --- a/killer/killer.cpp +++ b/killer/killer.cpp @@ -26,11 +26,14 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include +#include #include #include #include #include #include +#include int main(int argc, char* argv[]) { @@ -75,8 +78,20 @@ int main(int argc, char* argv[]) QStringList lst; lst << hostname << "kill" << QString::number(pid); QProcess::startDetached("xon", lst); - } else - ::kill(pid, SIGKILL); - XKillClient(QX11Info::display(), id); + } else { + if (::kill(pid, SIGKILL) && errno == EPERM) { + KAuth::Action killer("org.kde.ksysguard.processlisthelper.sendsignal"); + killer.setHelperID("org.kde.ksysguard.processlisthelper"); + killer.addArgument("pid0", pid); + killer.addArgument("pidcount", 1); + killer.addArgument("signal", SIGKILL); + if (killer.isValid()) { + kDebug(1212) << "Using KAuth to kill pid: " << pid; + killer.execute(); + } else { + kDebug(1212) << "KWin process killer action not valid"; + } + } + } } }