@@ -415,21 +415,13 @@ spawnChannelLocal proc = do
415415callLocal :: Process a -> Process a
416416callLocal proc = mask $ \release -> do
417417 mv <- liftIO newEmptyMVar :: Process (MVar (Either SomeException a))
418− child <- spawnLocal $ mask_ $ try (release proc) >>= liftIO . putMVar mv
419− ref <- monitor child
418+ (spInit, rpInit) <- newChan -- TODO: Remove when spawnLocal inherits the
419+ -- masking state.
420+ child <- spawnLocal $ mask_ $
421+ try (sendChan spInit () >> release proc) >>= liftIO . putMVar mv
420422 rs <- liftIO (takeMVar mv)
421423 `onException`
422− (do kill child "exception in parent process"
423− waitFor ref
424− )
424+ do receiveChan rpInit
425+ kill child "exception in parent process"
426+ liftIO (takeMVar mv)
425427 either throw return rs
426− where
427− -- TODO: when processes spawned with spawnLocal inherit the masking state of
428− -- the parent, this can be simplified to simply reading the MVar.
429− --
430− -- At the time of this writing, the spawned process is unmasked and can be
431− -- killed before the MVar is filled.
432− waitFor ref = receiveWait
433− [ matchIf (\(ProcessMonitorNotification ref' _ _) -> ref == ref')
434− (\_ -> return ())
435− ]