Skip to content

Commit

Permalink
Re haskell#7714: export ignoreSigPipe from D.Simple.Utils for `cabal …
Browse files Browse the repository at this point in the history
…man`
  • Loading branch information
andreasabel committed Jan 20, 2022
1 parent e5b148b commit 94b2342
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ library
GeneralizedNewtypeDeriving
ImplicitParams
KindSignatures
LambdaCase
NondecreasingIndentation
OverloadedStrings
RankNTypes
Expand Down
14 changes: 9 additions & 5 deletions Cabal/src/Distribution/Simple/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

-----------------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -42,6 +43,7 @@ module Distribution.Simple.Utils (

-- * exceptions
handleDoesNotExist,
ignoreSigPipe,

-- * running programs
rawSystemExit,
Expand Down Expand Up @@ -944,11 +946,13 @@ rawSystemStdInOut verbosity path args mcwd menv input _ = withFrozenCallStack $
Just ioe -> throwIO (ioeSetFileName ioe ("output of " ++ path))
Nothing -> throwIO exc

ignoreSigPipe :: IO () -> IO ()
ignoreSigPipe = Exception.handle $ \e -> case e of
GHC.IOError { GHC.ioe_type = GHC.ResourceVanished, GHC.ioe_errno = Just ioe }
| Errno ioe == ePIPE -> return ()
_ -> throwIO e
-- | Ignore SIGPIPE in a subcomputation.
--
ignoreSigPipe :: IO () -> IO ()
ignoreSigPipe = Exception.handle $ \case
GHC.IOError { GHC.ioe_type = GHC.ResourceVanished, GHC.ioe_errno = Just ioe }
| Errno ioe == ePIPE -> return ()
e -> throwIO e

-- | Look for a program and try to find it's version number. It can accept
-- either an absolute path or the name of a program binary, in which case we
Expand Down
4 changes: 2 additions & 2 deletions cabal-install/src/Distribution/Client/Manpage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Distribution.Client.Setup (globalCommand)
import Distribution.Simple.Command
import Distribution.Simple.Flag (fromFlagOrDefault)
import Distribution.Simple.Utils
( IOData(..), IODataMode(..), createProcessWithEnv, rawSystemStdInOut )
( IOData(..), IODataMode(..), createProcessWithEnv, ignoreSigPipe, rawSystemStdInOut )
import qualified Distribution.Verbosity as Verbosity
import System.IO (hClose, hPutStr)

Expand All @@ -54,7 +54,7 @@ manpageCmd pname commands flags
| fromFlagOrDefault False (manpageRaw flags)
= putStrLn contents
| otherwise
= do
= ignoreSigPipe $ do
-- 2021-10-08, issue #7714
-- @cabal man --raw | man -l -@ does not work on macOS/BSD,
-- because BSD-man does not support option @-l@, rather would
Expand Down

0 comments on commit 94b2342

Please sign in to comment.