From 3697ba0fd1406f30c756fed4e263d93dddcc6085 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Mon, 4 Jul 2005 04:39:44 +0000 Subject: [PATCH] Wrap exec, a la lambdabot --- src/plugins/System/Plugins/Utils.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/System/Plugins/Utils.hs b/src/plugins/System/Plugins/Utils.hs index fccf48d..8f9aa54 100644 --- a/src/plugins/System/Plugins/Utils.hs +++ b/src/plugins/System/Plugins/Utils.hs @@ -70,6 +70,7 @@ import Data.List import System.IO import System.Environment ( getEnv ) import System.Directory +import qualified Control.Exception as Control.Exception (handle) -- -- The fork library @@ -196,7 +197,10 @@ exec :: String -> [String] -> IO ([String],[String]) -- Needs to be compiled with -threaded for waitForProcess not to block -- exec prog args = do - (_,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing + Control.Exception.handle (\e -> return ([], [show e])) $ do + + (_inh,outh,errh,proc_hdl) <- runInteractiveProcess prog args Nothing Nothing + output <- hGetContents outh errput <- hGetContents errh forkIO (Control.Exception.evaluate (length output) >> return ())