summaryrefslogtreecommitdiff
path: root/Utility/Process.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-11-11 15:01:13 -0400
committerJoey Hess <joeyh@joeyh.name>2016-11-11 15:01:13 -0400
commit962e279e17c1f3cf3be49ffdfb5e7310711a220c (patch)
treed9953d9e57dea51c24ccaf4d7e64731010546f4f /Utility/Process.hs
parent7d7f93302c72cbe1a16598b0c90a49c10aaf3669 (diff)
downloadgit-repair-962e279e17c1f3cf3be49ffdfb5e7310711a220c.tar.gz
merge from git-annex
Diffstat (limited to 'Utility/Process.hs')
-rw-r--r--Utility/Process.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/Utility/Process.hs b/Utility/Process.hs
index c669996..ed02f49 100644
--- a/Utility/Process.hs
+++ b/Utility/Process.hs
@@ -18,6 +18,7 @@ module Utility.Process (
readProcessEnv,
writeReadProcessEnv,
forceSuccessProcess,
+ forceSuccessProcess',
checkSuccessProcess,
ignoreFailureProcess,
createProcessSuccess,
@@ -129,11 +130,12 @@ writeReadProcessEnv cmd args environ writestdin adjusthandle = do
-- | Waits for a ProcessHandle, and throws an IOError if the process
-- did not exit successfully.
forceSuccessProcess :: CreateProcess -> ProcessHandle -> IO ()
-forceSuccessProcess p pid = do
- code <- waitForProcess pid
- case code of
- ExitSuccess -> return ()
- ExitFailure n -> fail $ showCmd p ++ " exited " ++ show n
+forceSuccessProcess p pid = waitForProcess pid >>= forceSuccessProcess' p
+
+forceSuccessProcess' :: CreateProcess -> ExitCode -> IO ()
+forceSuccessProcess' _ ExitSuccess = return ()
+forceSuccessProcess' p (ExitFailure n) = fail $
+ showCmd p ++ " exited " ++ show n
-- | Waits for a ProcessHandle and returns True if it exited successfully.
-- Note that using this with createProcessChecked will throw away