diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-05-04 22:26:49 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-05-04 22:26:49 +0000 |
commit | 6c51183f0ebd48832b22e3e1ad587d2499dc65e9 (patch) | |
tree | c4feea1d9a868d82a1944ce678fcdcfaf46164b2 /libssh | |
parent | 61ebfcfa5cbd3de2d402fb6cc14448db79f0f685 (diff) | |
download | libssh-6c51183f0ebd48832b22e3e1ad587d2499dc65e9.tar.gz libssh-6c51183f0ebd48832b22e3e1ad587d2499dc65e9.tar.xz libssh-6c51183f0ebd48832b22e3e1ad587d2499dc65e9.zip |
Wait for the exit status before returning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@712 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh')
-rw-r--r-- | libssh/channels.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libssh/channels.c b/libssh/channels.c index 2525f15b..28dff7cb 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -1638,9 +1638,24 @@ SSH_SESSION *channel_get_session(CHANNEL *channel) { * * @param channel The channel to get the status from. * - * @return -1 if no exit status has been returned, the exit status othewise. + * @return -1 if no exit status has been returned or eof not sent, + * the exit status othewise. */ int channel_get_exit_status(CHANNEL *channel) { + if (channel->local_eof == 0) { + return -1; + } + + while (channel->remote_eof == 0 || channel->exit_status == -1) { + /* Parse every incoming packet */ + if (packet_wait(channel->session, 0, 0) != SSH_OK) { + return -1; + } + if (channel->open == 0) { + return -1; + } + } + return channel->exit_status; } |