Monitoring

One process Pid1 can monitor another process Pid2. If Pid2 terminates, Pid1 will receive a ‘DOWN’ message from Pid2.

  1. import Prelude
  2. import Control.Process (killProc)
  3. go :: forall a. IO a
  4. go = do
  5. pid <- spawn proc
  6. ref <- monitor pid
  7. killProc pid
  8. receive msg -> return msg
  9. proc :: Process ()
  10. proc = receive _ -> return ()