diff --git a/src/plugins/coreplugin/ssh/sftpchannel.cpp b/src/plugins/coreplugin/ssh/sftpchannel.cpp index cf4020c479311ea0c9833c929c5976ea2f90a694..4840e2ef5f50c8c844acbedc9c45be58816355ee 100644 --- a/src/plugins/coreplugin/ssh/sftpchannel.cpp +++ b/src/plugins/coreplugin/ssh/sftpchannel.cpp @@ -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 diff --git a/src/plugins/coreplugin/ssh/sftpchannel_p.h b/src/plugins/coreplugin/ssh/sftpchannel_p.h index 62163a6d5118266376f73d44ba3bb75d1c0a5249..23a37ebd60052778ace9f6b9a7f713753b37603f 100644 --- a/src/plugins/coreplugin/ssh/sftpchannel_p.h +++ b/src/plugins/coreplugin/ssh/sftpchannel_p.h @@ -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(); diff --git a/src/plugins/coreplugin/ssh/sshchannel.cpp b/src/plugins/coreplugin/ssh/sshchannel.cpp index 39c3fffbce1a83c222daa8fb0a6a151aa5306551..8d260c5ecd7ed0e1a869275cc58f5f59c0d6a7b8 100644 --- a/src/plugins/coreplugin/ssh/sshchannel.cpp +++ b/src/plugins/coreplugin/ssh/sshchannel.cpp @@ -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) diff --git a/src/plugins/coreplugin/ssh/sshchannel_p.h b/src/plugins/coreplugin/ssh/sshchannel_p.h index e0362c4642e709d1edb5c958ff1e010d8cc1fa4b..9546c6db891fe0d62271945aedebacb13b1e0227 100644 --- a/src/plugins/coreplugin/ssh/sshchannel_p.h +++ b/src/plugins/coreplugin/ssh/sshchannel_p.h @@ -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(); diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess.cpp b/src/plugins/coreplugin/ssh/sshremoteprocess.cpp index 0bd1439ce4f1ae785024be2d657906f0229b891a..6f6a1b7ab5adab95db1ccb8121f74e22bbde586f 100644 --- a/src/plugins/coreplugin/ssh/sshremoteprocess.cpp +++ b/src/plugins/coreplugin/ssh/sshremoteprocess.cpp @@ -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_procState = Exited; - } else if (requestType == SshIncomingPacket::ExitSignalType) { - const SshChannelExitSignal &signal = packet.extractChannelExitSignal(); + m_exitCode = exitStatus.exitStatus; + m_procState = Exited; +} + +void SshRemoteProcessPrivate::handleExitSignal(const SshChannelExitSignal &signal) +{ #ifdef CREATOR_SSH_DEBUG - qDebug("Exit due to signal %s", signal.signal.data()); + 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()); - } + setError(signal.error); + m_signal = signal.signal; + m_procState = Exited; } } // namespace Internal diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess_p.h b/src/plugins/coreplugin/ssh/sshremoteprocess_p.h index 50ea25e2d8585dc9612fc2691d9e99cbebccba83..284b822f9a2d86159c5cd27de7eda0cde1b68304 100644 --- a/src/plugins/coreplugin/ssh/sshremoteprocess_p.h +++ b/src/plugins/coreplugin/ssh/sshremoteprocess_p.h @@ -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);