Thank you Peter for your time and help.
Here is a extract from channel.c
* Return the channel's program exit status. Note that the actual protocol
* provides the full 32bit this function returns. We cannot abuse it to
* return error values in case of errors so we return a zero if channel is
Now this makes sense, but sending back zero seems peculiar to me.
zero is a valid shell exit code, so we should send back something out of
shell exit codes in case channel is None.
How about -1?
I have tried the SIGKILL, I get back a zero
Once again, thanks a lot for your help.
> Message: 4
> Date: Thu, 12 Jul 2012 18:44:38 +0200
> From: Peter Stuge <peter_at_stuge.se>
> To: libssh2-devel_at_cool.haxx.se
> Subject: Re: weird libssh2_channel_get_exit_status behaviour
> Message-ID: <20120712164438.4808.qmail_at_stuge.se>
> Content-Type: text/plain; charset=us-ascii
> aalok sood wrote:
> > libssh2_channel_get_exit_status documentation says that it returns 0
> > on error
> > How do I distinguish between and an Error and a exit_status of 0
> You can't. libssh2 would have to be extended in order to tell exit
> status 0 from an error. Feel free to do this and propose a patch.
> > I am not sure how I can handle the case where in the remote process
> > running the command got killed?
> This is a separate question, and the answer is that you can only do
> this by making the remote process handle the signal it gets sent, and
> exit with a special exit code, which signals that it was killed.
> Note that you can not handle SIGKILL. I am unsure what happens for
> that case, but I am also curious to know so please try it out and let
> us know.
> libssh2-devel mailing list
> End of libssh2-devel Digest, Vol 38, Issue 5
Received on 2012-07-14