From 4c5361d34d5f125ca7fca1f2dad505480b8a7692 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 29 Jun 2023 00:16:32 +0300 Subject: [PATCH] kinit: implement public cleanup method for klauncher to be used by ksmserver Signed-off-by: Ivailo Monev --- kinit/klauncher_adaptor.cpp | 25 +++++++++++++++---------- kinit/klauncher_adaptor.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/kinit/klauncher_adaptor.cpp b/kinit/klauncher_adaptor.cpp index bbb8bebc..7339b919 100644 --- a/kinit/klauncher_adaptor.cpp +++ b/kinit/klauncher_adaptor.cpp @@ -69,16 +69,7 @@ KLauncherAdaptor::KLauncherAdaptor(QObject *parent) KLauncherAdaptor::~KLauncherAdaptor() { kDebug() << "terminating processes" << m_processes.size(); - while (!m_processes.isEmpty()) { - QProcess* process = m_processes.takeLast(); - disconnect(process, 0, this, 0); - process->terminate(); - if (!process->waitForFinished(s_processtimeout)) { - kWarning() << "process still running" << process->pid(); - // SIGKILL is non-ignorable - process->kill(); - } - } + cleanup(); } void KLauncherAdaptor::autoStart(int phase) @@ -151,6 +142,20 @@ void KLauncherAdaptor::exec_blind(const QString &name, const QStringList &arg_li QProcess::startDetached(envexe, envargs); } +void KLauncherAdaptor::cleanup() +{ + while (!m_processes.isEmpty()) { + QProcess* process = m_processes.takeLast(); + disconnect(process, 0, this, 0); + process->terminate(); + if (!process->waitForFinished(s_processtimeout)) { + kWarning() << "process still running" << process->pid(); + // SIGKILL is non-ignorable + process->kill(); + } + } +} + int KLauncherAdaptor::kdeinit_exec(const QString &app, const QStringList &args, const QStringList &envs, const QString& startup_id) { return kdeinit_exec_with_workdir(app, args, envs, startup_id, QDir::currentPath()); diff --git a/kinit/klauncher_adaptor.h b/kinit/klauncher_adaptor.h index 9cfc4d2a..89da047e 100644 --- a/kinit/klauncher_adaptor.h +++ b/kinit/klauncher_adaptor.h @@ -54,6 +54,7 @@ public Q_SLOTS: // used by ksmserver and klauncher itself void exec_blind(const QString &name, const QStringList &arg_list); + void cleanup(); // used by KToolInvocation void setLaunchEnv(const QString &name, const QString &value);