[erlang-questions] Monitor vs. Link

Dave Smith <>
Fri Apr 4 00:25:55 CEST 2008


So I was sent a link to a talk done by Bob Ippolito (nice to put a
name with the face) :)

http://www.viddler.com/explore/rentzsch/videos/8/

In that video, Bob makes a glancing comment along the lines of:

"...you'll only see process_flag(trap_exit, true) in old code.
Typically you will use monitoring instead..."

This is interesting to me as I recently found myself using links +
trap_exit amongst some related processes and I wondered if the "Right
Way" would have been to use monitors instead. I do have a
bi-directional relationship between processes -- if one dies I want
the other to also (typically) do some shutdown. I could accomplish the
same thing with two monitors, but it seems like more work overall.

So, here's my question -- is there a reason to prefer using two
monitors to create a bi-directional monitor over link + trap_exit?
What's the best practice, particularly when one considers that I'm
using OTP patterns (gen_server and gen_fsm)?

Thanks,

D.



More information about the erlang-questions mailing list