Skip to content
  • Simon Marlow's avatar
    Windows: map ERROR_NO_DATA to EPIPE, rather than EINVAL · deea031d
    Simon Marlow authored
    WriteFile() returns ERROR_NO_DATA when writing to a pipe that is
    "closing", however by default the write() wrapper in the CRT maps this
    to EINVAL so we get confusing things like
    
      hPutChar: invalid argument (Invalid Argumnet)
    
    when piping the output of a Haskell program into something that closes
    the pipe early.  This was happening in the testsuite in a few place.
    
    The solution is to map ERROR_NO_DATA to EPIPE correctly, as we
    explicitly check for EPIPE on stdout (in GHC.TopHandler) so we can
    exit without an error in this case.
    deea031d