@@ -205,11 +205,10 @@ import Control.Distributed.Process.Internal.Messaging
205205 )
206206import Control.Distributed.Process.Internal.Primitives
207207 ( register
208− , finally
209208 , receiveWait
210209 , match
211210 , sendChan
212− , catch
211+ , try
213212 , unwrapMessage
214213 )
215214import Control.Distributed.Process.Internal.Types (SendPort, Tracer(..))
@@ -355,11 +354,10 @@ closeLocalNode node = do
355354runProcess :: LocalNode -> Process () -> IO ()
356355runProcess node proc = do
357356 done <- newEmptyMVar
358− tid <- myThreadId
359− void $ forkProcess node $ do
360− catch (proc `finally` liftIO (putMVar done ()))
361− (\(ex :: SomeException) -> liftIO $ throwTo tid ex)
362− takeMVar done
357+ -- TODO; When forkProcess inherits the masking state, protect the forked
358+ -- thread against async exceptions that could occur before 'try' is evaluated.
359+ void $ forkProcess node $ try proc >>= liftIO . putMVar done
360+ takeMVar done >>= either (throwIO :: SomeException -> IO a) return
363361
364362-- | Spawn a new process on a local node
365363forkProcess :: LocalNode -> Process () -> IO ProcessId