From d3807550470d6ca003705f9efcc422a93ec95572 Mon Sep 17 00:00:00 2001 From: lemmih Date: Thu, 25 Aug 2005 18:46:10 +0000 Subject: [PATCH] Report the error when a process returns a non-zero exit code. --- src/System/Plugins/Process.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/System/Plugins/Process.hs b/src/System/Plugins/Process.hs index eea1bb0..5a39a93 100644 --- a/src/System/Plugins/Process.hs +++ b/src/System/Plugins/Process.hs @@ -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