Besides avoiding propagated kills, is there any advantage to monitoring over just trapping exits?
Asked
Active
Viewed 640 times
2 Answers
11
Unlike trapping exits, monitoring allows you to easily keep tabs on processes that you have not spawned, and without having to trap exits. Also, links are bidirectional, so if you link to some process but you die first and it's not trapping exits, it dies too. Monitoring prevents this unintended coupling.

Steve Vinoski
- 19,847
- 3
- 31
- 46
1
There is never more than one link between two processes, while there can be several nested monitors.
10 seconds of googling... :-)

Greg
- 8,230
- 5
- 38
- 53
-
How does call use a monitor to get back a value? I thought monitors were only to get back exit values. – ForeverConfused Feb 13 '16 at 00:44
-
1Neither link nor monitor return exit values. They create a link/monitor and come back immediately. Later on, when the linked/monitored process crashes Erlang VM sends a message to the linked/monitoring process. The message is `{'DOWN', Ref, process, Pid2, Reason}` in case of monitors. See: http://erlang.org/doc/reference_manual/processes.html#id87043 – Greg Feb 13 '16 at 12:28