[erlang-questions] msg mailbox and gen_svr shutdown

Paweł Peregud paulperegud@REDACTED
Thu May 10 11:53:13 CEST 2012


I was having fun with supervisors yesterday (Cowboy seems to fail to
fulfill the promise of not killing request processes after listener
removal) and I have an example. I've only investigated the case when
supervisor is killed, so YMMV. Example code is attached. You may modify it
to check the behavior in your case.

Start supervisor tree with exp_sup_sup:start_link(). Execute test with
exp_sup_sup:test() and exp_sup_sup:test_simple().

In case of dying supervisor the answer is "no, it does not".

When supervisor dies, your process is killed as via link mechanism, so it
may leave some unprocessed messages in inbox. To make sure that every
delivered message is served, you need to add process_flag(trap_exit, true).
Messages that are sent after the moment when supervisor dies are not
processed.

Best regards,

Paul.

On May 9, 2012 11:06 AM, "Andy Richards" <andy.richards.iit@REDACTED>
wrote:

> Hi,
>
> I can't seem to see any confirmation in the documentation so was wondering
> if anyone could confirm if messages are still sent to a supervised gen_svr
> following a shutdown message?
>
> If so how do I cleanly shutdown my gen_svr without loosing messages? I
> read in the supervisor child spec that a shutdown can be set to infinity
> which i hoped would allow me to process the msg's in my mailbox but if I do
> this will my module continue to receive messages from other processes? Is
> my approach flawed and if so what other ways are there to cleanly shutting
> down my gen_svr without loosing messages?
>
> Many thanks,
>
> Andy.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120510/f2d95f32/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.zip
Type: application/zip
Size: 2372 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120510/f2d95f32/attachment.zip>


More information about the erlang-questions mailing list