Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runShellCommands hangs on reading output #47

Open
dminuoso opened this issue Oct 15, 2018 · 2 comments
Open

runShellCommands hangs on reading output #47

dminuoso opened this issue Oct 15, 2018 · 2 comments

Comments

@dminuoso
Copy link

Hi,

runShellCommands did not work for me, it hung on reading the output on the first command.

After reading the connection protocol specs and your implementation I'm almost convinced that the implementation cannot work for the following reasons:

  1. A shell is requested
  2. Some data is written to the channel as the "command"
  3. readAllChannel tries to read in 1KiB chunks until it reads an empty string
    3.1. For each chunkreadChannelEx calls into libssh2_channel_read_ex attempting to read 1KiB
    3.2 This ends up eventually calling _libssh2_channel_read which returns the number of bytes read
    3.3 That function will only return 0 bytes only if the remote sent an EOF or the channel was closed, otherwise it will either read something or produce EAGAIN.

This loop would terminate only if an EOF was sent or the channel was closed.

Am I looking at this wrong?

@dminuoso
Copy link
Author

I mean this might work if the remote side sends an EOF appropriately, but none of the devices I've tried it against do this. Your library does not look like you blindly committed code, so Im curious how you justify the code. :)

@dminuoso dminuoso changed the title runShellCommands runShellCommands hangs on reading output Oct 15, 2018
@portnov
Copy link
Owner

portnov commented Oct 19, 2018

Hello.
I can't tell that runShellCommands function is well-tested. It may be working in some circumstances. I do not actually use it in my other projects; but I use execCommand function from libssh2-conduit package (lives in this repo too), and can say that it is working. If you know how to patch the runShellCommands function, please feel free to make a pull request :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants