Commit 63b5b21c authored by byorgey's avatar byorgey
Browse files

D.C.Compat.Process.readProcessWithExitCode: also catch permission errors

Closes #1613.
parent 2502ea1b
......@@ -24,7 +24,7 @@ import Prelude hiding (catch)
import Control.Exception (catch, throw)
import System.Exit (ExitCode (ExitFailure))
import System.IO.Error (isDoesNotExistError)
import System.IO.Error (isDoesNotExistError, isPermissionError)
import qualified System.Process as P
-- | @readProcessWithExitCode@ creates an external process, reads its
......@@ -38,11 +38,12 @@ import qualified System.Process as P
-- The version from @System.Process@ behaves inconsistently across
-- platforms when an executable with the given name is not found: in
-- some cases it returns an @ExitFailure@, in others it throws an
-- exception. This variant catches \"does not exist\" exceptions and
-- turns them into @ExitFailure@s.
-- exception. This variant catches \"does not exist\" and
-- \"permission denied\" exceptions and turns them into
-- @ExitFailure@s.
readProcessWithExitCode :: FilePath -> [String] -> String -> IO (ExitCode, String, String)
readProcessWithExitCode cmd args input =
P.readProcessWithExitCode cmd args input
`catch` \e -> if isDoesNotExistError e
`catch` \e -> if isDoesNotExistError e || isPermissionError e
then return (ExitFailure 127, "", "")
else throw e
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment