www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: libssh2_channel_get_exit_status

Re: libssh2_channel_get_exit_status

From: aalok sood <aalok_at_ideadevice.com>
Date: Sat, 13 Oct 2012 04:15:21 +0530

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-request_at_cool.haxx.se> wrote:

> Send libssh2-devel mailing list submissions to
> libssh2-devel_at_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-request_at_cool.haxx.se
>
> You can reach the person managing the list at
> libssh2-devel-owner_at_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 <aalok_at_ideadevice.com>
> To: libssh2-devel_at_cool.haxx.se
> Subject: Re: libssh2_channel_get_exit_status (Daniel Stenberg)
> Message-ID:
> <
> CAG+SKy5o_0hJYHWhLSMWS2O9LWHzniHWUKYe0jYrFYpQP5mg1w_at_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 <daniel_at_haxx.se>
> > To: libssh2 development <libssh2-devel_at_cool.haxx.se>
> > Subject: Re: libssh2_channel_get_exit_status
> > Message-ID: <alpine.DEB.2.00.1207152353050.5683_at_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_at_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 <peter_at_stuge.se>
> To: libssh2-devel_at_cool.haxx.se
> Subject: Re: libssh2_channel_get_exit_status (Daniel Stenberg)
> Message-ID: <20120716110432.8470.qmail_at_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_at_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
Received on 2012-10-13

the libssh2 team