-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
ShellStream.Read not blocking when no data available #63
Comments
While looking more further to the ShellStream class I think that the What do you think about implementing blocking behavior for the |
I agree that we should probably do this. |
I agree. Read needs to block. It's useless (at least for me) without blocking |
Hello, If some is interested i can provide a patch for the current version (I´m still using the last release from CodePlex). It will possible also solve other Issues i found here. |
I would very much like the fix detailed by @oblaise integrated into the next release. Interacting with devices that don't implement the exec channel correctly force interactive terminal emulation, and the fact that Read() does not block makes it very difficult to properly do this. After patching in @oblaise 's fix and using it, my code works correctly. WIthout it, because .Read() immediately returns the 0 byte read, nothing is output. |
Trying to push towards vNext milestone. The PR only fixes the OP's issue as it is indisputably a bug. It is hard to reason about the problem with |
I basically created a new Pipe class which is handling the blocking until one side is closed. This new class can also be used with the Shell: Also one example for the SshCommand:
}` |
I think that when moving to .netstandard 2.0 as a min requirement you should consider the https://devblogs.microsoft.com/dotnet/system-io-pipelines-high-performance-io-in-net/ |
This issue has been fixed in the 2024.0.0 version. |
ShellStream.Read returns immediately with 0 bytes read when no data is available instead of blocking the call.
Consequently the other functions implemented in the parent class
Stream
that implement the asynchronous patterns based on the Read function (BeginRead/EndRead, ReadAsync) return also immediately with a 0 byte read instead of being suspended until data is available.This prevent using correct asynchronous pattern with these functions.
The following modified function waiting on
_dataReceived
when no data is available seems to work:The text was updated successfully, but these errors were encountered: