From a5cf6f194d79f67a99263cf7d6f07d41b79d5239 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 14 Dec 2018 10:12:59 +0100 Subject: [PATCH] SSH: Fix exit status/exit code interpretation A "regular" exit of the ssh binary with exit code 255 means that the remote process has crashed. Change-Id: I82e6e44079041459e78e4f8f7e7b6e5cbcaa6c44 Reviewed-by: Ulf Hermann --- src/libs/ssh/sshremoteprocess.cpp | 7 ++++++- .../projectexplorer/devicesupport/sshdeviceprocess.cpp | 6 +++--- .../projectexplorer/devicesupport/sshdeviceprocess.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libs/ssh/sshremoteprocess.cpp b/src/libs/ssh/sshremoteprocess.cpp index 22e28131505..ca38f48b398 100644 --- a/src/libs/ssh/sshremoteprocess.cpp +++ b/src/libs/ssh/sshremoteprocess.cpp @@ -68,7 +68,12 @@ SshRemoteProcess::SshRemoteProcess(const QByteArray &command, const QStringList connect(this, static_cast(&QProcess::finished), [this] { - emit done(exitStatus() == QProcess::NormalExit ? QString() : errorString()); + QString error; + if (exitStatus() == QProcess::CrashExit) + error = tr("The ssh binary crashed: %1").arg(errorString()); + else if (exitCode() == 255) + error = tr("Remote process crashed."); + emit done(error); }); connect(this, &QProcess::errorOccurred, [this](QProcess::ProcessError error) { if (error == QProcess::FailedToStart) diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index e3cc959a5d1..4f447214f5e 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -139,7 +139,7 @@ QProcess::ProcessState SshDeviceProcess::state() const QProcess::ExitStatus SshDeviceProcess::exitStatus() const { - return d->exitStatus == QSsh::SshRemoteProcess::NormalExit + return d->exitStatus == QSsh::SshRemoteProcess::NormalExit && d->exitCode != 255 ? QProcess::NormalExit : QProcess::CrashExit; } @@ -223,9 +223,9 @@ void SshDeviceProcess::handleProcessStarted() emit started(); } -void SshDeviceProcess::handleProcessFinished() +void SshDeviceProcess::handleProcessFinished(const QString &error) { - d->errorMessage = d->process->errorString(); + d->errorMessage = error; d->exitCode = d->process->exitCode(); d->setState(SshDeviceProcessPrivate::Inactive); emit finished(); diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h index 7bbe942354e..8c1da7cf558 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h @@ -60,7 +60,7 @@ private: void handleConnectionError(); void handleDisconnected(); void handleProcessStarted(); - void handleProcessFinished(); + void handleProcessFinished(const QString &error); void handleStdout(); void handleStderr(); void handleKillOperationFinished(const QString &errorMessage);