[erlang-questions] How to clean up before termination...
Tue Mar 20 17:29:21 CET 2012
You may have mis-read the documentation slightly, or else I misunderstand
If trap_exit is set to true then the terminate function is called when the
gen_server is shutting down, if it is false then the terminate function is
never called. All cleanup should be done in terminate, nowhere else.
Is this what you're asking?
On Tue, Mar 20, 2012 at 4:17 PM, Dawid Figiel <>wrote:
> There is a recommendation in Erlang doc, which is telling to set up
> the trap_exit to true in the gen_server:init, when want to do clean up
> before supervisor will terminate the gen_server.
> My question is:
> What for trap_exit has to be set to true when the clean up is needed?
> The place for doing some clean ups is under terminate function.
> We want to have trape_exit set to true when we need to handle 'EXIT'
> signals coming from linked processes to (for example) not crash
> The only explanation for me is that the supervisor may crash too and
> send 'Exit' to gen_server as well... but this doesn't convince even
> Has anyone some explanation for this advice ?
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions