Skip to content
Snippets Groups Projects
Commit 12fda1a0 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

RemoteLinux: Fix remote processes listing.

There were nul character conversion problems, resulting in display
artifacts.

Change-Id: Ia012d18c942e6b31029054a1574c04e0c3d182b7
Reviewed-on: http://codereview.qt-project.org/5397


Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent e97c828e
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ namespace RemoteLinux { ...@@ -44,7 +44,7 @@ namespace RemoteLinux {
namespace Internal { namespace Internal {
namespace { namespace {
enum State { Inactive, Listing, Killing }; enum State { Inactive, Listing, Killing };
const char Delimiter[] = "-----"; const char Delimiter[] = "x-----";
} // anonymous namespace } // anonymous namespace
class AbstractRemoteLinuxProcessListPrivate class AbstractRemoteLinuxProcessListPrivate
...@@ -176,8 +176,10 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus) ...@@ -176,8 +176,10 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus)
break; break;
case SshRemoteProcess::ExitedNormally: case SshRemoteProcess::ExitedNormally:
if (d->process->process()->exitCode() == 0) { if (d->process->process()->exitCode() == 0) {
if (d->state == Listing) if (d->state == Listing) {
d->remoteProcesses = buildProcessList(QString::fromUtf8(d->remoteStdout)); d->remoteProcesses = buildProcessList(QString::fromUtf8(d->remoteStdout.data(),
d->remoteStdout.count()));
}
} else { } else {
d->errorMsg = tr("Remote process failed."); d->errorMsg = tr("Remote process failed.");
} }
...@@ -232,7 +234,8 @@ GenericRemoteLinuxProcessList::GenericRemoteLinuxProcessList(const LinuxDeviceCo ...@@ -232,7 +234,8 @@ GenericRemoteLinuxProcessList::GenericRemoteLinuxProcessList(const LinuxDeviceCo
QString GenericRemoteLinuxProcessList::listProcessesCommandLine() const QString GenericRemoteLinuxProcessList::listProcessesCommandLine() const
{ {
return QString::fromLocal8Bit("for dir in `ls -d /proc/[0123456789]*`; " return QString::fromLocal8Bit("for dir in `ls -d /proc/[0123456789]*`; "
"do echo $dir%1`cat $dir/cmdline`%1`cat $dir/stat`; done").arg(Delimiter); "do printf \"${dir}%1\";cat $dir/cmdline; printf '%1';cat $dir/stat;printf '\\n'; done")
.arg(Delimiter);
} }
QString GenericRemoteLinuxProcessList::killProcessCommandLine(const RemoteProcess &process) const QString GenericRemoteLinuxProcessList::killProcessCommandLine(const RemoteProcess &process) const
...@@ -243,7 +246,7 @@ QString GenericRemoteLinuxProcessList::killProcessCommandLine(const RemoteProces ...@@ -243,7 +246,7 @@ QString GenericRemoteLinuxProcessList::killProcessCommandLine(const RemoteProces
QList<AbstractRemoteLinuxProcessList::RemoteProcess> GenericRemoteLinuxProcessList::buildProcessList(const QString &listProcessesReply) const QList<AbstractRemoteLinuxProcessList::RemoteProcess> GenericRemoteLinuxProcessList::buildProcessList(const QString &listProcessesReply) const
{ {
QList<RemoteProcess> processes; QList<RemoteProcess> processes;
const QStringList &lines = listProcessesReply.split(QLatin1Char('\n')); const QStringList &lines = listProcessesReply.split(QLatin1Char('\n'), QString::SkipEmptyParts);
foreach (const QString &line, lines) { foreach (const QString &line, lines) {
const QStringList elements = line.split(QString::fromLocal8Bit(Delimiter)); const QStringList elements = line.split(QString::fromLocal8Bit(Delimiter));
if (elements.count() < 3) { if (elements.count() < 3) {
...@@ -257,6 +260,7 @@ QList<AbstractRemoteLinuxProcessList::RemoteProcess> GenericRemoteLinuxProcessLi ...@@ -257,6 +260,7 @@ QList<AbstractRemoteLinuxProcessList::RemoteProcess> GenericRemoteLinuxProcessLi
continue; continue;
} }
QString command = elements.at(1); QString command = elements.at(1);
command.replace(QLatin1Char('\0'), QLatin1Char(' '));
if (command.isEmpty()) { if (command.isEmpty()) {
const QString &statString = elements.at(2); const QString &statString = elements.at(2);
const int openParenPos = statString.indexOf(QLatin1Char('(')); const int openParenPos = statString.indexOf(QLatin1Char('('));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment