kinit: implement public cleanup method for klauncher

to be used by ksmserver

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-29 00:16:32 +03:00
parent ee9ca6e533
commit 4c5361d34d
2 changed files with 16 additions and 10 deletions

View file

@ -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());

View file

@ -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);