Commit 68f86a94 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

RemoteLinux: Don't rely on the presence of pkill.



Change-Id: Iad42c1c356d9c3914e46082decc0a38d844ed98d
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent cf1f5b95
......@@ -212,24 +212,6 @@ void MaemoSshRunner::unmount()
}
}
QString MaemoSshRunner::killApplicationCommandLine() const
{
// Prevent pkill from matching our own pkill call.
QString pkillArg = remoteExecutable();
const int lastPos = pkillArg.count() - 1;
pkillArg.replace(lastPos, 1, QLatin1Char('[') + pkillArg.at(lastPos) + QLatin1Char(']'));
// Fremantle's busybox configuration is strange.
const char *killTemplate;
if (devConfig()->osType() == QLatin1String(Maemo5OsType))
killTemplate = "pkill -f -%2 %1";
else
killTemplate = "pkill -%2 -f %1";
const QString niceKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGTERM");
const QString brutalKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGKILL");
return niceKill + QLatin1String("; sleep 1; ") + brutalKill;
}
} // namespace Internal
} // namespace Madde
......@@ -65,7 +65,6 @@ private:
void doAdditionalInitializations();
void doPostRunCleanup();
void doAdditionalConnectionErrorHandling();
QString killApplicationCommandLine() const;
void mount();
void unmount();
......
......@@ -450,6 +450,17 @@ void AbstractRemoteLinuxApplicationRunner::handlePostRunCleanupDone()
emit error(tr("Error running remote process: %1").arg(d->runner->errorString()));
}
QString AbstractRemoteLinuxApplicationRunner::killApplicationCommandLine() const
{
return QString::fromLocal8Bit("cd /proc; for pid in `ls -d [0123456789]*`; "
"do "
"if [ \"`readlink /proc/$pid/exe`\" = \"%1\" ]; then "
" kill $pid; sleep 1; kill -9 $pid; "
"fi; "
"done").arg(remoteExecutable());
}
const qint64 AbstractRemoteLinuxApplicationRunner::InvalidExitCode = std::numeric_limits<qint64>::min();
......@@ -488,18 +499,5 @@ void GenericRemoteLinuxApplicationRunner::doAdditionalConnectionErrorHandling()
{
}
QString GenericRemoteLinuxApplicationRunner::killApplicationCommandLine() const
{
// Prevent pkill from matching our own pkill call.
QString pkillArg = remoteExecutable();
const int lastPos = pkillArg.count() - 1;
pkillArg.replace(lastPos, 1, QLatin1Char('[') + pkillArg.at(lastPos) + QLatin1Char(']'));
const char * const killTemplate = "pkill -%2 -f %1";
const QString niceKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGTERM");
const QString brutalKill = QString::fromLocal8Bit(killTemplate).arg(pkillArg).arg("SIGKILL");
return niceKill + QLatin1String("; sleep 1; ") + brutalKill;
}
} // namespace RemoteLinux
......@@ -105,7 +105,7 @@ private slots:
private:
virtual QString killApplicationCommandLine() const = 0;
virtual QString killApplicationCommandLine() const;
// Implement to do custom setup of the device *before* connecting.
// Call handleDeviceSetupDone() afterwards.
......@@ -145,9 +145,6 @@ protected:
void doAdditionalInitializations();
void doPostRunCleanup();
void doAdditionalConnectionErrorHandling();
private:
QString killApplicationCommandLine() const;
};
} // namespace RemoteLinux
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment