SV: Killing Supervisor
Fri Apr 28 08:56:18 CEST 2006
Surindar Sivanesan wrote:
> I thank Serge, Lennart and Samuel for the reply to my doubt.
> But still I haven't get the clear idea of stopping the entire supervision
> tree. Kindly do my favour.
> On 4/26/06, Samuel Rivas wrote:
> Lennart Öhman wrote:
> > If you simply do exit(Pid,kill) on the supervisor, it will not
> > be given the chance of terminating its children in an ordered
> > way.
> Calling exit(SupervisorPid, shutdown) in the supervisor's parent
> process would do the trick.
Take a look to Erlang Design Principles, specially to:
OTP behaviours define a standard shutdown process. The clean way to
shutdown a supervisor is, as Lennart said, to make it child of another
supervisor and use supervisor API to stop it. Obviously, you need a top
supervisor. You can shutdown the top supervisor if you start it as part
of an OTP application.
What happens with the two workarounds proposed is:
- exit(Pid, kill) sends Pid an exit signal that cannot be trapped, so
the supervisor dies instantaneously and the exit signal propagates
to its children since they are linked. Children die in an unspecified
- exit(Pid, shutdown) makes what a parent supervisor would do to
terminate the supervisor. That way, the supervisor receives the
signal, stops its children cleanly and terminates itself.
More information about the erlang-questions