Supervisor shutdown

Gunilla Arendt gunilla@REDACTED
Tue Nov 25 11:52:20 CET 2003


No, the supervisor *is* required to call start_link!
Simply linking is not enough, as the gen_server can be linked to any
process but it must also be able to separate EXIT signals from its
supervisor from other EXIT signals! That is what start_link ensures.

And yes, there are alternative start strategies that in retrospect
might have been better choices. For example, simply providing
the supervisor with the name of the callback module(s) and make it
responsible for starting its child processes the correct way.

Best regards, Gunilla


Vlad Dumitrescu wrote:
> 
> 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

-- 
_____Gunilla Arendt______________________________________________
EAB/UKH/KD Erlang/OTP Product Development
Gunilla.Arendt@REDACTED  +46-8-7275730  ecn 851 5730



More information about the erlang-questions mailing list