-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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.WaitForExit() deadlocks when waiting on "dotnet.exe build /m /nr:true" #2981
Comments
Hello, I hit a bug similar to what I described in dotnet/runtime#41752 and I think this is due to this issue. |
The So the issue is that we are waiting a stdout/stderr Pipe that won't close, the child process itself is gone. |
Like I commented in the initial PR, I think the ideal way is to fix the root bug, the issue where I reported this bug on the runtime repo dotnet/runtime#51277 have been in |
Yes, I would like to have a fix in runtime, but the workaround you proposed was simple and it worked when I tried it. I decided it would be faster to use it now without waiting for runtime patch. Unfortunately, there are some consequences I didn't predict. |
I did warn it right below the workaround that it would truncate the output.
Well if nobody triage the issue I don't think the patch will be done anytime soon. |
Repro Steps
A. Uses
msbuild.exe
anddotnet.exe
from%PATH%
.WaitForExit()
works fine withmsbuild.exe /m /nr:true
.WaitForExit()
deadlocks withdotnet.exe build /m /nr:true
.Root Cause
WaitForExit()
has a bug/behavior where it will wait for all child processes to exit if the parent process output is being read asynchronously (https://stackoverflow.com/a/37983587/102052). The workaround is to callWaitForExit(int.MaxValue)
instead, which does not wait for the child processes to exit.Conclusion
I created this issue for MSBuild since the behavior is inconsistent between
msbuild.exe
anddotnet.exe build
. If the only impact of this inconsistency isWaitForExit()
, it's probably a low priority to change. However, it could be a symptom of other possible problems with the waydotnet.exe
child processes are created.The text was updated successfully, but these errors were encountered: