merge from propellor

This commit is contained in:
Joey Hess 2016-03-06 20:07:38 -04:00
parent a07fd19ce9
commit 9a8cdc3652
Failed to extract signature

View file

@ -18,6 +18,7 @@ module Utility.Process (
readProcessEnv, readProcessEnv,
writeReadProcessEnv, writeReadProcessEnv,
forceSuccessProcess, forceSuccessProcess,
forceSuccessProcess',
checkSuccessProcess, checkSuccessProcess,
ignoreFailureProcess, ignoreFailureProcess,
createProcessSuccess, createProcessSuccess,
@ -129,12 +130,12 @@ writeReadProcessEnv cmd args environ writestdin adjusthandle = do
-- | Waits for a ProcessHandle, and throws an IOError if the process -- | Waits for a ProcessHandle, and throws an IOError if the process
-- did not exit successfully. -- did not exit successfully.
forceSuccessProcess :: CreateProcess -> ProcessHandle -> IO () forceSuccessProcess :: CreateProcess -> ProcessHandle -> IO ()
forceSuccessProcess p pid = do forceSuccessProcess p pid = waitForProcess pid >>= forceSuccessProcess' p
code <- waitForProcess pid
case code of forceSuccessProcess' :: CreateProcess -> ExitCode -> IO ()
ExitSuccess -> return () forceSuccessProcess' _ ExitSuccess = return ()
ExitFailure n -> ioError $ userError $ forceSuccessProcess' p (ExitFailure n) = fail $
showCmd p ++ " exited " ++ show n showCmd p ++ " exited " ++ show n
-- | Waits for a ProcessHandle and returns True if it exited successfully. -- | Waits for a ProcessHandle and returns True if it exited successfully.
-- Note that using this with createProcessChecked will throw away -- Note that using this with createProcessChecked will throw away