There are two extra callbacks you might want to implement for this. These are callbacks on the channel, so you're pretty close already.
The first is request_exit_status
. Once you implement this, Conch will no longer log that the exit-status
request is unhandled. Here's an example implementation:
def request_exit_status(self, data):
"""
When the server sends the command's exit status, record it for later
delivery to the protocol.
@param data: The network-order four byte representation of the exit
status of the command.
@type data: L{bytes}
"""
(status,) = unpack('>L', data)
if status != 0:
self._reason = ProcessTerminated(status, None, None)
The second is request_exit_signal
. exit-signal
is sent instead of exit-status
if the command is terminated by a signal. Here's an example implementation:
def request_exit_signal(self, data):
"""
When the server sends the command's exit status, record it for later
delivery to the protocol.
@param data: The network-order four byte representation of the exit
signal of the command.
@type data: L{bytes}
"""
(signal,) = unpack('>L', data)
self._reason = ProcessTerminated(None, signal, None)
The general pattern here is that when SSHChannel
receives a request for foo it will try to call request_foo
with the bytes making up the request.