Report the error when a process returns a non-zero exit code.
This commit is contained in:
parent
5d2b4db2a8
commit
d380755047
@ -6,6 +6,7 @@
|
|||||||
--
|
--
|
||||||
module System.Plugins.Process (exec, popen) where
|
module System.Plugins.Process (exec, popen) where
|
||||||
|
|
||||||
|
import System.Exit
|
||||||
#if __GLASGOW_HASKELL__ >= 604
|
#if __GLASGOW_HASKELL__ >= 604
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Process
|
import System.Process
|
||||||
@ -59,9 +60,12 @@ popen file args minput =
|
|||||||
forkIO (Control.Exception.evaluate (length errput) >> return ())
|
forkIO (Control.Exception.evaluate (length errput) >> return ())
|
||||||
|
|
||||||
-- And now we wait. We must wait after we read, unsurprisingly.
|
-- And now we wait. We must wait after we read, unsurprisingly.
|
||||||
waitForProcess pid -- blocks without -threaded, you're warned.
|
exitCode <- waitForProcess pid -- blocks without -threaded, you're warned.
|
||||||
|
case exitCode of
|
||||||
return (output,errput,pid)
|
ExitFailure code
|
||||||
|
| null errput -> let errMsg = file ++ ": failed with error code " ++ show code
|
||||||
|
in return ([],errMsg,error errMsg)
|
||||||
|
_ -> return (output,errput,pid)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user