From 404b797779ae2d94372b4fce94301b5556ad1d56 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 11 Jul 2011 12:51:36 +0200 Subject: [PATCH] MeeGo: Fix process killing for long application names. QTCREATORBUG-5141 Change-Id: I92017c1892ccc76a396c10d9aee49ece10df4574 Reviewed-on: http://codereview.qt.nokia.com/1414 Reviewed-by: Qt Sanity Bot Reviewed-by: Christian Kandeler --- .../remotelinuxapplicationrunner.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp index 340f4154bbf..6234edea860 100644 --- a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp +++ b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp @@ -41,8 +41,6 @@ #include #include -#include - #include #define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state) @@ -65,7 +63,12 @@ RemoteLinuxApplicationRunner::RemoteLinuxApplicationRunner(QObject *parent, m_stopRequested(false), m_state(Inactive) { - m_procsToKill << QFileInfo(m_remoteExecutable).fileName(); + // Prevent pkill from matching our own pkill call. + QString pkillArg = m_remoteExecutable; + const int lastPos = pkillArg.count() - 1; + pkillArg.replace(lastPos, 1, QLatin1Char('[') + pkillArg.at(lastPos) + QLatin1Char(']')); + m_procsToKill << pkillArg; + connect(m_portsGatherer, SIGNAL(error(QString)), SLOT(handlePortsGathererError(QString))); connect(m_portsGatherer, SIGNAL(portListReady()), SLOT(handleUsedPortsAvailable())); } @@ -181,8 +184,13 @@ void RemoteLinuxApplicationRunner::cleanup() emit reportProgress(tr("Killing remote process(es)...")); - // pkill behaves differently on Fremantle and Harmattan. - const char *const killTemplate = "pkill -%2 '^%1$'; pkill -%2 '/%1$';"; + // Fremantle's busybox configuration is strange. + const char *killTemplate; + if (m_devConfig->osType() == LinuxDeviceConfiguration::Maemo5OsType) + killTemplate = "pkill -f -%2 %1;"; + else + killTemplate = "pkill -%2 -f %1;"; + QString niceKill; QString brutalKill; foreach (const QString &proc, m_procsToKill) { @@ -221,6 +229,7 @@ void RemoteLinuxApplicationRunner::handleCleanupFinished(int exitStatus) if (exitStatus != SshRemoteProcess::ExitedNormally) { emitError(tr("Initial cleanup failed: %1").arg(m_cleaner->errorString())); + emit remoteProcessFinished(InvalidExitCode); return; }