[erlang-questions] "simple_one_for_one" supervisor childs termination problem

Lukas Larsson <>
Tue Nov 30 12:09:56 CET 2010


When terminating a child the supervisor calls exit(Pid,shutdown). When a
process receives an exit signal it will automatically die unless it is
trapping exits. So in order for terminate to be called before the process
dies you have to trap exits within the child process.

This is described in the gen_server Design Principles documentation:
http://www.erlang.org/doc/design_principles/gen_server_concepts.html#id62546

Lukas

On Tue, Nov 30, 2010 at 11:58 AM, zabrane Mikael <> wrote:

> Hi everybody,
>
> I'm testing a "simple_one_for_one" supervisor (foo_sup.erl) to
> supervise a bunch of workers (foo_srv.erl implemented as gen_server).
> On the top of that, there's an application process (foo_app.erl) which
> let me start/stop the entire application easily.
> Everything went fine except the termination.
>
> When calling "application:stop(foo_app)", the workers never get their
> "terminate/2" function called.
>
> Here's my supervisor (foo_sup.erl) init/1 function:
> init([]) ->
>    AChild = {foo_srv, {foo_srv, start_link, []},
>                   transient, 180000, worker, [foo_srv]},
>    Strategy = {simple_one_for_one, 10, 100},
>    {ok, {Strategy, [AChild]}}.
>
>
> Any help will be very appreciated!
>
>
> N.B: it seems to me that the Erlang doc is also missing the fact the
> atom 'infinity'
> couldn't be use with simple_one_for_one. Am I right? So in this
> example, I'm using a kill timeout of 3 minutes (18000).
>
> --
> Regards
> Zabrane
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


More information about the erlang-questions mailing list