forked from qt-creator/qt-creator
SSH: Handle exit-status and exit-signal in SFTP channels as well.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "sftpchannel_p.h"
|
||||
|
||||
#include "sshexception_p.h"
|
||||
#include "sshincomingpacket_p.h"
|
||||
#include "sshsendfacility_p.h"
|
||||
|
||||
#include <QtCore/QDir>
|
||||
@@ -248,6 +249,22 @@ void SftpChannelPrivate::handleChannelExtendedDataInternal(quint32 type,
|
||||
data.data(), type);
|
||||
}
|
||||
|
||||
void SftpChannelPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
||||
{
|
||||
const char * const message = "Remote SFTP service exited with exit code %d";
|
||||
#ifdef CREATOR_SSH_DEBUG
|
||||
qDebug(message, exitStatus.exitStatus);
|
||||
#else
|
||||
if (exitStatus.exitStatus != 0)
|
||||
qWarning(message, exitStatus.exitStatus);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SftpChannelPrivate::handleExitSignal(const SshChannelExitSignal &signal)
|
||||
{
|
||||
qWarning("Remote SFTP service killed; signal was %s", signal.signal.data());
|
||||
}
|
||||
|
||||
void SftpChannelPrivate::handleCurrentPacket()
|
||||
{
|
||||
#ifdef CREATOR_SSH_DEBUG
|
||||
|
@@ -75,6 +75,8 @@ private:
|
||||
virtual void handleChannelDataInternal(const QByteArray &data);
|
||||
virtual void handleChannelExtendedDataInternal(quint32 type,
|
||||
const QByteArray &data);
|
||||
virtual void handleExitStatus(const SshChannelExitStatus &exitStatus);
|
||||
virtual void handleExitSignal(const SshChannelExitSignal &signal);
|
||||
|
||||
void handleCurrentPacket();
|
||||
void handleServerVersion();
|
||||
|
@@ -202,8 +202,14 @@ void AbstractSshChannel::handleChannelExtendedData(quint32 type, const QByteArra
|
||||
|
||||
void AbstractSshChannel::handleChannelRequest(const SshIncomingPacket &packet)
|
||||
{
|
||||
qWarning("Ignoring unknown request type '%s'",
|
||||
packet.extractChannelRequestType().data());
|
||||
checkChannelActive();
|
||||
const QByteArray &requestType = packet.extractChannelRequestType();
|
||||
if (requestType == SshIncomingPacket::ExitStatusType)
|
||||
handleExitStatus(packet.extractChannelExitStatus());
|
||||
else if (requestType == SshIncomingPacket::ExitSignalType)
|
||||
handleExitSignal(packet.extractChannelExitSignal());
|
||||
else
|
||||
qWarning("Ignoring unknown request type '%s'", requestType.data());
|
||||
}
|
||||
|
||||
int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &data)
|
||||
|
@@ -39,6 +39,8 @@ QT_FORWARD_DECLARE_CLASS(QTimer);
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class SshChannelExitSignal;
|
||||
class SshChannelExitStatus;
|
||||
class SshIncomingPacket;
|
||||
class SshSendFacility;
|
||||
|
||||
@@ -61,7 +63,6 @@ public:
|
||||
|
||||
virtual void handleChannelSuccess()=0;
|
||||
virtual void handleChannelFailure()=0;
|
||||
virtual void handleChannelRequest(const SshIncomingPacket &packet);
|
||||
|
||||
virtual void closeHook()=0;
|
||||
|
||||
@@ -73,6 +74,7 @@ public:
|
||||
void handleChannelClose();
|
||||
void handleChannelData(const QByteArray &data);
|
||||
void handleChannelExtendedData(quint32 type, const QByteArray &data);
|
||||
void handleChannelRequest(const SshIncomingPacket &packet);
|
||||
|
||||
void requestSessionStart();
|
||||
void sendData(const QByteArray &data);
|
||||
@@ -100,6 +102,8 @@ private:
|
||||
virtual void handleChannelDataInternal(const QByteArray &data)=0;
|
||||
virtual void handleChannelExtendedDataInternal(quint32 type,
|
||||
const QByteArray &data)=0;
|
||||
virtual void handleExitStatus(const SshChannelExitStatus &exitStatus)=0;
|
||||
virtual void handleExitSignal(const SshChannelExitSignal &signal)=0;
|
||||
|
||||
void setState(ChannelState newState);
|
||||
void flushSendBuffer();
|
||||
|
@@ -210,28 +210,23 @@ void SshRemoteProcessPrivate::handleChannelExtendedDataInternal(quint32 type,
|
||||
emit errorOutputAvailable(data);
|
||||
}
|
||||
|
||||
void SshRemoteProcessPrivate::handleChannelRequest(const SshIncomingPacket &packet)
|
||||
void SshRemoteProcessPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
||||
{
|
||||
checkChannelActive();
|
||||
const QByteArray &requestType = packet.extractChannelRequestType();
|
||||
if (requestType == SshIncomingPacket::ExitStatusType) {
|
||||
const SshChannelExitStatus status = packet.extractChannelExitStatus();
|
||||
#ifdef CREATOR_SSH_DEBUG
|
||||
qDebug("Process exiting with exit code %d", status.exitStatus);
|
||||
qDebug("Process exiting with exit code %d", exitStatus.exitStatus);
|
||||
#endif
|
||||
m_exitCode = status.exitStatus;
|
||||
m_exitCode = exitStatus.exitStatus;
|
||||
m_procState = Exited;
|
||||
} else if (requestType == SshIncomingPacket::ExitSignalType) {
|
||||
const SshChannelExitSignal &signal = packet.extractChannelExitSignal();
|
||||
}
|
||||
|
||||
void SshRemoteProcessPrivate::handleExitSignal(const SshChannelExitSignal &signal)
|
||||
{
|
||||
#ifdef CREATOR_SSH_DEBUG
|
||||
qDebug("Exit due to signal %s", signal.signal.data());
|
||||
#endif
|
||||
setError(signal.error);
|
||||
m_signal = signal.signal;
|
||||
m_procState = Exited;
|
||||
} else {
|
||||
qWarning("Ignoring unknown request type '%s'", requestType.data());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -70,7 +70,8 @@ private:
|
||||
virtual void handleChannelDataInternal(const QByteArray &data);
|
||||
virtual void handleChannelExtendedDataInternal(quint32 type,
|
||||
const QByteArray &data);
|
||||
virtual void handleChannelRequest(const SshIncomingPacket &packet);
|
||||
virtual void handleExitStatus(const SshChannelExitStatus &exitStatus);
|
||||
virtual void handleExitSignal(const SshChannelExitSignal &signal);
|
||||
|
||||
void setProcState(ProcessState newState);
|
||||
|
||||
|
Reference in New Issue
Block a user