[erlang-questions] supervisors, gen_server:terminate/2, and trap_exit

Fred Hebert mononcqc@REDACTED
Thu Mar 12 13:25:23 CET 2015


On 03/12, Imants Cekusins wrote:
> actually, terminate _is_ called also after gs process crashes while executing.
> 
> so the exceptions are:
> 1) gs is unconditionally terminated using exit(Child,kill).
> 2) VM crash, power down & other calamities

Each behaviour callback is usually in a 'try ... catch', so programming
errors within a behaviour would end up executing 'terminate' before the
process exits (gen_event handlers are *removed* when that happens, but
the process stays up).

However, any link, not just an explicit call to exit/2, can end up
killing the process without calling terminate/2. So if I link(OtherPid)
and OtherPid dies without me trapping exits, the signal is never
converted to a message and my process wil die. If the process is
trapping exits, then only exit(Pid, Kill) will take the process down
brutally, along with the other VM- or System-wide stuff you mentioned.

Regards,
Fred.



More information about the erlang-questions mailing list