You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Analyzer Proposal]: Avoid deadlocking patterns for System.Diagnostics.Process #119650
I was investigating System.Diagnostics.Process issues today, and found out along the way some common patterns that can easily lead to deadlocks.
Calling process.[StandardOutput|StandardError].ReadToEnd() (or awaiting the async variant) after waiting for process exit. This can lead to deadlock if the child process attempts to write to stdout/stderr more than 4kb (the current buffer size). The child process will only be able to write the first 4kb of data, then it cannot write more data unless the written data is consumed by the parent process. But the parent process is waiting for process exit first before consuming the stream. So this will cause a deadlock.
Even with the order swapped, deadlocks can happen when both StdOut and StdErr are waited on sequentially.
API Proposal
Analyzer the warns when such patterns are detected.
An analyzer here should now account for the new process APIs and suggest these. That should also help more with visibility of the new APIs and increase its adoption. cc @adamsitnik
Activity
dotnet-policy-service commentedon Sep 12, 2025
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.
Youssef1313 commentedon May 18, 2026
An analyzer here should now account for the new process APIs and suggest these. That should also help more with visibility of the new APIs and increase its adoption. cc @adamsitnik