Report the error when a process returns a non-zero exit code.

This commit is contained in:
lemmih 2005-08-25 18:46:10 +00:00
parent 5d2b4db2a8
commit d380755047

View File

@ -6,6 +6,7 @@
--
module System.Plugins.Process (exec, popen) where
import System.Exit
#if __GLASGOW_HASKELL__ >= 604
import System.IO
import System.Process
@ -59,9 +60,12 @@ popen file args minput =
forkIO (Control.Exception.evaluate (length errput) >> return ())
-- And now we wait. We must wait after we read, unsurprisingly.
waitForProcess pid -- blocks without -threaded, you're warned.
return (output,errput,pid)
exitCode <- waitForProcess pid -- blocks without -threaded, you're warned.
case exitCode of
ExitFailure code
| null errput -> let errMsg = file ++ ": failed with error code " ++ show code
in return ([],errMsg,error errMsg)
_ -> return (output,errput,pid)
#else