Skip to content

[System.Console] Behavior of piping into a bad/nonexistent program on Unix #15587

Closed

Description

@mellinoe

Right now, if you try to pipe a program's output into a non-existent program on Unix, you will get an IOException on the first call to Console.Write(Line) (and probably other paths):

Unhandled Exception: System.IO.IOException: Broken pipe
   at Interop.CheckIo(Int64 result, String path, Boolean isDirectory, Func`2 errorRewriter)
   at System.ConsolePal.Write(Int32 fd, Byte[] buffer, Int32 offset, Int32 count)
   at System.ConsolePal.UnixConsoleStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.SyncTextWriter.WriteLine(String value)
   at System.Console.WriteLine(String value)

I chatted with Stephen briefly and we thought that it might be sensible to just ignore this particular exception (in Interop.CheckIO) and allow the program to continue. That is, if we are able to easily detect such a case, and are still able to correctly throw if some other error occurs. How do others feel about this? This seems to be in line with what other programs do if piped into a bad program.

Activity

  1. transferred this issue fromdotnet/corefxon Jan 31, 2020
  2. added this to the 1.0.0-rtm milestone on Jan 31, 2020
  3. ghost locked as resolved and limited conversation to collaborators on Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions