diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-03-06 20:21:30 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-03-06 20:21:30 -0400 |
| commit | d09a67ea25be77300a4eeb06b7c922b0c28c5d25 (patch) | |
| tree | 3c8ff1da309e72cf0d601b25f973859b9006c1c6 /src | |
| parent | c4e2006f00ff78d56d3f4ad815564b53e87ec9fb (diff) | |
refactor
Diffstat (limited to 'src')
| -rw-r--r-- | src/Utility/Process.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Utility/Process.hs b/src/Utility/Process.hs index c6699961e..ed02f49e 100644 --- a/src/Utility/Process.hs +++ b/src/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 |
