Supervisor shutdown

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Tue Nov 25 11:34:08 CET 2003


From: "Ulf Wiger" <ulf.wiger@REDACTED>
> >> So how do I stop the application  and ensure that my gen_server
> >> terminate code
> > gets executed??
> >
> > If the gen_server is part of a supervision tree and is ordered by its
> > supervisor to terminate, this function will be called with
> > Reason=shutdown if the following conditions apply:
> >     -the gen_server has been set to trap exit signals, and
> >     -the shutdown strategy as defined in the supervisor's
> >      child specification is an integer timeout value,
> >      not brutal_kill.
>
> ...and the gen_server has been started with gen_server:start_link(...),
> not gen_server:start(...).

Mmmm, not necessarily with start_link. The child can use any function to start,
but it is *required* to create the link in some way.
However, I haven't seen yet any child using something else than start_link :-)

BTW, wouldn't it be better if the supervisor would check that the link was
created, or maybe better, create it itself? Since the specs make the link
mandatory, why not impose the requirement in the code too?

regards,
Vlad



More information about the erlang-questions mailing list