Trying to understand GenServer terminate/2 behavior when trapping exit

One of the elements of the contract of the OTP special process (and GenServer is such a process) is to die when it receives an EXIT message from parent. That’s what you’re seeing - the parent EXIT message is intercepted by GenServer internals and causes a suicide of the server.

http://erlang.org/doc/design_principles/spec_proc.html

If the special process is set to trap exits and if the parent process terminates, the expected behavior is to terminate with the same reason:

2 Likes