[erlang-questions] gen_server and exit(Pid, shutdown)

Alexander Petrovsky askjuise@REDACTED
Fri May 4 18:23:23 CEST 2018


Hello!

After a long timer working with Erlang and using gen_server abstraction,
I've discovered for myself that when I send exit(Pid, shutdown) for some
gen_server (or when application stopping), according to the documentation,
terminate callback will be called only when trap_exit flag is true. In my
mind it's absolutely not intuitively, the documentation very clear
for trap_exit and it's says:

When a process is trapping exits, it does not terminate when an exit signal
> is received. Instead, the signal is transformed into a message
> {'EXIT',FromPid,Reason}, which is put into the mailbox of the process,
> just like a regular message.


So, I suppose to see the message {'EXIT', FromPid, shutdown} in
handle_info when
I call exit(GenServerPid, shutdown), and I always suppose, that terminate
callback will be called (of course I remeber about reason kill)

--
Петровский Александр / Alexander Petrovsky,

Skype: askjuise
Phone: +7 931 9877991
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180504/e2c184cc/attachment.htm>


More information about the erlang-questions mailing list