@@ -345,8 +345,15 @@ call dict nid proc = do
345345 (\(ProcessMonitorNotification _ _ reason) -> return (Left reason))
346346 ]
347347 case mResult of
348− Right a -> unmonitor mRef >> return a
349− Left err -> fail $ "call: remote process died: " ++ show err
348+ Right a -> do
349+ -- Wait for the monitor message so that we the mailbox doesn't grow
350+ receiveWait
351+ [ matchIf (\(ProcessMonitorNotification ref _ _) -> ref == mRef)
352+ (\(ProcessMonitorNotification {}) -> return ())
353+ ]
354+ return a
355+ Left err ->
356+ fail $ "call: remote process died: " ++ show err
350357
351358-- | Spawn a child process, have the child link to the parent and the parent
352359-- monitor the child