summaryrefslogtreecommitdiffstats
path: root/wayland/democompositor/processlauncher.cpp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-11-25 12:42:28 +0100
committerHolger Freyther <holger+qt@freyther.de>2017-11-29 02:13:28 +0000
commit163764be406dd6f64dbd4affd6c294359f00501e (patch)
treeae381fcc9049b69686cbb9838639cf5fa09c7894 /wayland/democompositor/processlauncher.cpp
parentf73fdd97d4bf70b02aac4c0b680a51e632f732eb (diff)
democompositor: Introduce a graceful stop of a client application
Use SIGTERM to terminate the application but to make sure it will go away create a unique timer and start it. The timer is owned by the QProcess and will go away once the process has terminated. On timeout use SIGKILL to make sure the process is going away. Change-Id: I9f9617a579952697aa61bd7bfa1d2fd264a443ce Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'wayland/democompositor/processlauncher.cpp')
-rw-r--r--wayland/democompositor/processlauncher.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/wayland/democompositor/processlauncher.cpp b/wayland/democompositor/processlauncher.cpp
index 6147f05..29e4d64 100644
--- a/wayland/democompositor/processlauncher.cpp
+++ b/wayland/democompositor/processlauncher.cpp
@@ -52,6 +52,7 @@
#include "apps/appentry.h"
#include <QProcess>
+#include <QTimer>
Q_LOGGING_CATEGORY(procs, "launcher.procs")
@@ -118,6 +119,24 @@ void WaylandProcessLauncher::kill(const AppEntry& entry)
}
}
+void WaylandProcessLauncher::stop(const AppEntry& entry, int ms)
+{
+ for (auto state : m_appStates) {
+ if (state.appEntry.sourceFileName != entry.sourceFileName)
+ continue;
+
+ auto timer = new QTimer(state.process);
+ connect(timer, &QTimer::timeout, [entry, state, timer] {
+ qCDebug(procs) << "Sending SIGKILL " << state.process->pid() << " for " << entry.sourceFileName;
+ timer->deleteLater();
+ state.process->kill();
+ });
+ timer->start(ms);
+ qCDebug(procs) << "Sending SIGTERM " << state.process->pid() << " for " << entry.sourceFileName;
+ state.process->terminate();
+ }
+}
+
void WaylandProcessLauncher::launch(const AppEntry &entry)
{
qCDebug(procs) << "Launching" << entry.executableName;