[erlang-questions] supervisors, gen_server:terminate/2, and trap_exit
Thu Mar 12 14:10:21 CET 2015
On 03/12, Imants Cekusins wrote:
> thank you Fred!
> sorry, another question:
> so gen_X:start is (among other things) a spawn with no link, no trapping
> and gen_X:start_link is spawn + link + trap exits?
- No behaviour traps exits automatically except supervisors. That's for
you to decide.
- gen_x:start has no link. they are not meant to be used in supervision
trees (the doc mentions, for gen_server:start/3-4: "Creates a
stand-alone gen_server process, i.e. a gen_server which is not part of
a supervision tree and thus has no supervisor.")
- start_link is spawn+link
> OTP are always started via either start or start_link,
Whatever goes in a supervision tree *needs* start_link.
> so a gs needs to spawn a non-OTP process, explicitly link to it and
> not trap exits to put its terminate at risk?
*Any* process that sets up a link will put it at risk if they don't trap
exit, whether it's OTP or not. Links are a primitive of Erlang. OTP is a
framework on top. No OTP behaviour traps exits by default (outside of
'supervisor'). Exit signals sent over links to processes will work the
same everywhere, and will be altered the same way everywhere when
More information about the erlang-questions