-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Process.OutputDataReceived not firing #28025
Comments
Any news about that^^? I wasn't able to find anything to workaround this. It actually breaks my whole parent/child console logging |
No news, other than it is a bug. The implementation in core is assuming that once canceled, it should stop processing permanently, which is not what the docs describe:
|
@stephentoub maybe I found the issue CancelOutputRead signal CTS of |
@MarcoRossignoli, it's a bit more than that; the whole reading implementation is broken for this case, as to match what the docs describe, it shouldn't stop reading at all when cancellation occurs... instead it needs to continue to read and buffer, just not invoke the callback, as netfx does. If you want to try fixing it, go for it :) |
Oh sorry I did't read properly...risky behaviour could lead to OOM, isn't it? |
I guess it would not read anything from the underlying stream in that case. This would not OOM but not allow the pipe to drain. It might block the child process (which is a common bug when someone forgets to read StdErr). So that risk is nothing new and it's an esoteric scenario to stop reading output after you have started. Actually, I wonder what your scenario is. Why are you doing this? |
Unfortunately both the docs and the netfx implementation disagree: "All further redirected output to StandardOutput is saved in a buffer. If you re-enable the event handler with a call to BeginOutputReadLine, the saved output is sent to the event handler and asynchronous read operations resume."
Yes, but it is what it is.
I agree. In which case I think it's better to be compatible with netfx and the docs. |
Man, the |
@stephentoub silly question...If I would like to know if some api will throw PNSE on some plat without using analyzer?Is there a way to infer it from documentation? |
I don't believe docs have been updated with that information, at least not fully. |
@stephentoub seems that netfx doesn't respect guide, I did some tests and on "cancel state" code drain queue https://referencesource.microsoft.com/#System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs,278 |
Can you share your tests? |
Sure dotnet/corefx@master...MarcoRossignoli:process |
You're right. This call: |
Should I open an issue on docs repo? |
Sure, thanks. |
So we actually have two issues here?
|
@MarcoRossignoli is this fixed, with your change? I'm now confused as to what this issue tracks that's left. |
@danmosemsft we need to merge dotnet/corefx#33974 to fix it. The other PR is for guide that I fixed dotnet/dotnet-api-docs#1467 |
I'm using something like an attach/detach function to get the process console output redirected to a main console only.
To achieve this I'm using the process.BeginOutputReadLine and process.CancelOutputRead for my attach/detach together with the OutputDataReceived event.
However I noticed that after calling process.CancelOutputRead once and using process.BeginOutputReadLine after that, the OutputDataReceived won't fire at all.
I created a test console app with .NET Core 2.2 and .NET Core 3.0 and faced this issue on both.
I also created a console app with .NET Framework 4.7 and it work's without problems there, so it looks like a .NET Core specific problem.
I found the issue https://github.com/dotnet/corefx/issues/31740 and used the test code from it and adjusted it a bit, but not sure if it's related to this:
.NET Core --info
The text was updated successfully, but these errors were encountered: