@@ -56,7 +56,7 @@ import Control.Exception
5656 , Exception
5757 , throwTo
5858 )
59−import qualified Control.Exception as Exception (catch, finally)
59+import qualified Control.Exception as Exception (Handler(..), catch, catches, finally)
6060import Control.Concurrent (forkIO, myThreadId)
6161import Control.Distributed.Process.Internal.StrictMVar
6262 ( newMVar
@@ -177,6 +177,7 @@ import Control.Distributed.Process.Internal.Primitives
177177 , match
178178 , sendChan
179179 , catch
180+ , unwrapMessage
180181 )
181182import Control.Distributed.Process.Internal.Types (SendPort)
182183import qualified Control.Distributed.Process.Internal.Closure.BuiltIn as BuiltIn (remoteTable)
@@ -349,9 +350,15 @@ forkProcess node proc = modifyMVar (localState node) startProcess
349350 , processNode = node
350351 }
351352 tid' <- forkIO $ do
352− reason <- Exception.catch
353+ reason <- Exception.catches
353354 (runLocalProcess lproc proc >> return DiedNormal)
354− (return . DiedException . (show :: SomeException -> String))
355+ [ (Exception.Handler (\ex@(ProcessExitException from msg) -> do
356+ mMsg <- unwrapMessage msg :: IO (Maybe String)
357+ case mMsg of
358+ Nothing -> return $ DiedException $ show ex
359+ Just m -> return $ DiedException ("exit-from=" ++ (show from) ++ ",reason=" ++ m)))
360+ , (Exception.Handler
361+ (return . DiedException . (show :: SomeException -> String)))]
355362
356363 -- [Unified: Table 4, rules termination and exiting]
357364 modifyMVar_ (localState node) (cleanupProcess pid)