mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
channel_get_exit_status()
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@228 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -253,6 +253,7 @@ int channel_is_closed(CHANNEL *channel);
|
|||||||
int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct
|
int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct
|
||||||
timeval * timeout);
|
timeval * timeout);
|
||||||
SSH_SESSION *channel_get_session(CHANNEL *channel);
|
SSH_SESSION *channel_get_session(CHANNEL *channel);
|
||||||
|
int channel_get_exit_status(CHANNEL *channel);
|
||||||
/* in options.c */
|
/* in options.c */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -284,6 +284,7 @@ struct channel_struct {
|
|||||||
void *userarg;
|
void *userarg;
|
||||||
int version;
|
int version;
|
||||||
int blocking;
|
int blocking;
|
||||||
|
int exit_status;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct agent_struct {
|
struct agent_struct {
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ CHANNEL *channel_new(SSH_SESSION *session){
|
|||||||
channel->prev=session->channels->prev;
|
channel->prev=session->channels->prev;
|
||||||
channel->next->prev=channel;
|
channel->next->prev=channel;
|
||||||
channel->prev->next=channel;
|
channel->prev->next=channel;
|
||||||
|
channel->exit_status=-1;
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,6 +300,7 @@ static void channel_rcv_request(SSH_SESSION *session){
|
|||||||
ssh_log(session,SSH_LOG_PACKET,"received exit-status");
|
ssh_log(session,SSH_LOG_PACKET,"received exit-status");
|
||||||
buffer_get_u32(session->in_buffer,&status);
|
buffer_get_u32(session->in_buffer,&status);
|
||||||
status=ntohl(status);
|
status=ntohl(status);
|
||||||
|
channel->exit_status=status;
|
||||||
/* TODO do something with status, we might need it */
|
/* TODO do something with status, we might need it */
|
||||||
free(request_s);
|
free(request_s);
|
||||||
free(request);
|
free(request);
|
||||||
@@ -955,6 +957,16 @@ SSH_SESSION *channel_get_session(CHANNEL *channel){
|
|||||||
return channel->session;
|
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. */
|
/* This function acts as a meta select. */
|
||||||
/* first, channels are analyzed to seek potential can-write or can-read ones. */
|
/* 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) */
|
/* Then, if no channel has been elected, it goes in a loop with the posix select(2) */
|
||||||
|
|||||||
5
sample.c
5
sample.c
@@ -180,7 +180,9 @@ void select_loop(SSH_SESSION *session,CHANNEL *channel){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(lus==0){
|
if(lus==0){
|
||||||
ssh_say(1,"EOF received\n");
|
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
|
||||||
|
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
|
||||||
|
|
||||||
channel_free(channel);
|
channel_free(channel);
|
||||||
channel=channels[0]=NULL;
|
channel=channels[0]=NULL;
|
||||||
} else
|
} else
|
||||||
@@ -194,6 +196,7 @@ void select_loop(SSH_SESSION *session,CHANNEL *channel){
|
|||||||
}
|
}
|
||||||
if(lus==0){
|
if(lus==0){
|
||||||
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
|
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
|
||||||
|
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
|
||||||
channel_free(channel);
|
channel_free(channel);
|
||||||
channel=channels[0]=NULL;
|
channel=channels[0]=NULL;
|
||||||
} else
|
} else
|
||||||
|
|||||||
Reference in New Issue
Block a user