On May 17, 2012, at 6:02 AM, Peter Stuge wrote:
> Sorry, but that's not correct. Please look at the documentation
> and/or play around more with the examples.
I am. A lot. The documentation nor the examples have big conceptual overviews and it was putting my code aside to use the example which lead me into this problem in the first place.
The ssh_exec example does not read at all from stderr and it *only* looks for read returning 0 to determine the remote side has finished executing. According to the ssh_exec example, if there is possibly going to be more data, you'll get EAGAIN, if not, you'll get 0.
Assuming that was correct, that had me scratching my head why sometimes I'd get an eof, and sometimes I wouldn't. That's why I wondered if (in non-blocking land) 0 on read was effectively an eof, and the eof didn't happen every time because of some difference in how the remotely executed command behaved.
The reason I never got an eof in ssh_exec though turns out to simply be because the code (which I was relying on for correct usage) was not reading from stderr, and there was still data on it. ssh_exec doesn't read from stderr, nor does echo, and the documentation doesn't say anywhere that you need to, in order to reach eof. That may be second nature to you, but as a newcomer, I have no idea how libssh2 is supposed to be used, and I wrongly (in this case) assumed the examples would show me, since the documentation doesn't cover high level concepts.
And a quick note, the documentation says for libssh2_channel_eof: "Check if the remote host has sent an EOF status for the selected stream." What selected stream?
-- Seth Willits _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-develReceived on 2012-05-17