summaryrefslogtreecommitdiffstats
path: root/libssh/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'libssh/channels.c')
-rw-r--r--libssh/channels.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libssh/channels.c b/libssh/channels.c
index 33c86407..26409b85 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -57,6 +57,7 @@ CHANNEL *channel_new(SSH_SESSION *session){
channel->prev=session->channels->prev;
channel->next->prev=channel;
channel->prev->next=channel;
+ channel->exit_status=-1;
return channel;
}
@@ -299,6 +300,7 @@ static void channel_rcv_request(SSH_SESSION *session){
ssh_log(session,SSH_LOG_PACKET,"received exit-status");
buffer_get_u32(session->in_buffer,&status);
status=ntohl(status);
+ channel->exit_status=status;
/* TODO do something with status, we might need it */
free(request_s);
free(request);
@@ -955,6 +957,16 @@ SSH_SESSION *channel_get_session(CHANNEL *channel){
return channel->session;
}
+/** \brief get the exit status of the channel (error code from the executed instruction).
+ * \param channel channel
+ * \return -1 no exit status was returned.
+ * \return other values : exit status
+ */
+
+int channel_get_exit_status(CHANNEL *channel){
+ return channel->exit_status;
+}
+
/* This function acts as a meta select. */
/* first, channels are analyzed to seek potential can-write or can-read ones. */
/* Then, if no channel has been elected, it goes in a loop with the posix select(2) */