- AsyncException UserInterrupt -> exitInterrupted
-
- -- only the main thread gets ExitException exceptions
- ExitException ExitSuccess -> exit 0
- ExitException (ExitFailure n) -> exit n
-
- other -> do
- reportError other
- exit 1
+ Just UserInterrupt -> exitInterrupted
+
+ _ -> case cast exn of
+ -- only the main thread gets ExitException exceptions
+ Just ExitSuccess -> exit 0
+ Just (ExitFailure n) -> exit n
+
+ -- EPIPE errors received for stdout are ignored (#2699)
+ _ -> case cast exn of
+ Just IOError{ ioe_type = ResourceVanished,
+ ioe_errno = Just ioe,
+ ioe_handle = Just hdl }
+ | Errno ioe == ePIPE, hdl == stdout -> exit 0
+ _ -> do reportError se
+ exit 1