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
Add API for detecting broken pipe when write to stdout(or stderr) #30540
This behavior is sometimes inconvenient when work together with some command like head command.
if dotnet command output is very long, there is no easy way to stop program if command which follows after pipe stop (except using native API, but it is sometimes very difficult).
So, I want the API to detect whether stdout(and maybe stderr) is broken.
Triage: I don't believe that we can provide reliable API for this feature request. To check whether pipe is broken, we would need to perform a write. Writing 0 bytes has a special meaning (#81053), so writing 0 bytes is not an option. Changing the behavior to always throw in such cases is also not an option, as it would break plenty of apps (especially those which are printing to console while the process is shutting down).
Since there was only one up-vote, the best I can do right now is to provide a workaround:
Activity
adamsitnik commentedon Nov 14, 2023
Triage: I don't believe that we can provide reliable API for this feature request. To check whether pipe is broken, we would need to perform a write. Writing 0 bytes has a special meaning (#81053), so writing 0 bytes is not an option. Changing the behavior to always throw in such cases is also not an option, as it would break plenty of apps (especially those which are printing to console while the process is shutting down).
Since there was only one up-vote, the best I can do right now is to provide a workaround: