module Turtle.Internal ( ignoreSIGPIPE ) where import Control.Exception (handle, throwIO) import Foreign.C.Error (Errno(..), ePIPE) import GHC.IO.Exception (IOErrorType(..), IOException(..)) ignoreSIGPIPE :: IO () -> IO () ignoreSIGPIPE :: IO () -> IO () ignoreSIGPIPE = (IOException -> IO ()) -> IO () -> IO () forall e a. Exception e => (e -> IO a) -> IO a -> IO a handle (\IOException e -> case IOException e of IOError { ioe_type :: IOException -> IOErrorType ioe_type = IOErrorType ResourceVanished , ioe_errno :: IOException -> Maybe CInt ioe_errno = Just CInt ioe } | CInt -> Errno Errno CInt ioe Errno -> Errno -> Bool forall a. Eq a => a -> a -> Bool == Errno ePIPE -> () -> IO () forall (m :: * -> *) a. Monad m => a -> m a return () IOException _ -> IOException -> IO () forall e a. Exception e => e -> IO a throwIO IOException e )