[erlang-questions] How to clean up before termination...

dmitry kolesnikov dmkolesnikov@REDACTED
Tue Mar 20 17:43:42 CET 2012


Hi,

In some cases a gen_server might spawn a linked child processes. You
might want to flush some buffers on disk if one of child dies. But
this is really an application specific. In most of cases you can
ignore it. Simply let it fail!

Best Regards,
Dmitry >-|-|-*>


On 20.3.2012, at 18.17, Dawid Figiel <dawid.figiel@REDACTED> wrote:

> Hi,
>
> 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.
>
> http://www.erlang.org/doc/design_principles/gen_server_concepts.html#id66567
>
> 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
> gen_server.
>
> 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
> myself.
>
> Has anyone some explanation for this advice ?
>
>
> Best,
>
> Dawid
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list