Hi After much ado, I finally got some space and time to work on the patch. However, I see further issues with how libssh2_channel_get_exit_status() works. The exit_status field in channel structured is initialized to 0. Now in cases where in we received a unexpected eof and hence did not receive the exit status at all, the api libssh2_channel_get_exit_status() still returns 0 (which is a valid ssh code).
The fix I have done on my local setup is to initialize channel->exit_status as -1. Now when I call libssh2_channel_get_exit_status, I know for sure that an exit code has been received or not. I realize that we can also overcome this problem by keeping a flag exit_code_received (which be set only if exit code is actually received), and return that in the new api: LIBSSH2_API int libssh2_channel_get_exit_status2(LIBSSH2_CHANNEL *channel, uint32_t *status) However I feel this is a serious issue in the existing api and must be fixed there as well. This pushes me towards the original fix, ie. to initialize exit_status to a non valid ssh return code. Regards Aalok On Tue, Jul 17, 2012 at 3:30 PM, <libssh2-devel-requ...@cool.haxx.se> wrote: > Send libssh2-devel mailing list submissions to > libssh2-devel@cool.haxx.se > > To subscribe or unsubscribe via the World Wide Web, visit > http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel > or, via email, send a message with subject or body 'help' to > libssh2-devel-requ...@cool.haxx.se > > You can reach the person managing the list at > libssh2-devel-ow...@cool.haxx.se > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of libssh2-devel digest..." > > > Today's Topics: > > 1. Re: libssh2_channel_get_exit_status (Daniel Stenberg) (aalok sood) > 2. Re: libssh2_channel_get_exit_status (Daniel Stenberg) > (Peter Stuge) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 16 Jul 2012 15:45:17 +0530 > From: aalok sood <aa...@ideadevice.com> > To: libssh2-devel@cool.haxx.se > Subject: Re: libssh2_channel_get_exit_status (Daniel Stenberg) > Message-ID: > < > cag+sky5o_0hjyhwhlsmws2o9lwhznihwukye0jyrfypqp5m...@mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Yes Daniel I agree with you. > > It would be better than modifying libssh2_channel_get_exit_status. > Also keeping the fetch status in a separate field from the actual shell > exit_status would be a better, more clear api. > > I will add the api and send in a patch. > > -(Aalok)- > > > > > Message: 2 > > Date: Sun, 15 Jul 2012 23:55:36 +0200 (CEST) > > From: Daniel Stenberg <dan...@haxx.se> > > To: libssh2 development <libssh2-devel@cool.haxx.se> > > Subject: Re: libssh2_channel_get_exit_status > > Message-ID: <alpine.deb.2.00.1207152353050.5...@tvnag.unkk.fr> > > Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed > > > > On Sun, 15 Jul 2012, aalok sood wrote: > > > > > * libssh2_channel_get_exit_status > > > > > > 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 valid > > shell > > > exit codes in case channel is None. How about -1? > > > > We should rather make a new function that has a prototype like: > > > > LIBSSH2_API int > > libssh2_channel_get_exit_status2(LIBSSH2_CHANNEL *channel, uint32_t > > *status) > > > > Which then can return the proper value from the protocol in a value > > separate > > from the return code. Wouldn't that work fine for you? > > > > -- > > > > > > > / daniel.haxx.se > > > > > > ------------------------------ > > > > _______________________________________________ > > libssh2-devel mailing list > > libssh2-devel@cool.haxx.se > > http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel > > > > > > End of libssh2-devel Digest, Vol 38, Issue 7 > > ******************************************** > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://cool.haxx.se/pipermail/libssh2-devel/attachments/20120716/a3beb8ab/attachment-0001.html > > > > ------------------------------ > > Message: 2 > Date: Mon, 16 Jul 2012 13:04:32 +0200 > From: Peter Stuge <pe...@stuge.se> > To: libssh2-devel@cool.haxx.se > Subject: Re: libssh2_channel_get_exit_status (Daniel Stenberg) > Message-ID: <20120716110432.8470.qm...@stuge.se> > Content-Type: text/plain; charset=us-ascii > > aalok sood wrote: > > I will add the api and send in a patch. > > Remember to include documentation. > > > //Peter > > > ------------------------------ > > _______________________________________________ > libssh2-devel mailing list > libssh2-devel@cool.haxx.se > http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel > > > End of libssh2-devel Digest, Vol 38, Issue 8 > ******************************************** >
_______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel