tracking failures in supervisor:start_link

Samuel Rivas samuel@REDACTED
Thu Feb 2 14:57:53 CET 2006


Gunilla Arendt wrote:
> Samuel Rivas wrote:
> > Hi,
> >
> > If any of the child processes dies in the init phase when a supervisor is
> > created with start_link, the supervisor terminates itself with the
> > reason shutdown. I'd prefer the exit message to propagate untouched, so
> > I need to know the initial exit reason.
> >
> > The only way I came up with is creating the supervisor with an empty
> > child list, starting the children afterwards with the start_child
> > function. That way the supervisor returns {error, Reason} if something
> > fails in the children's init functions. This is not perfect since I
> > cannot know whether the child process died or returned {error, Reason}
> > but is better than the initial case.
> >
> > Any cleaner way to do that?
> 
> [...]
> So the short answer to your question is 'no'.
> 
> I would recommend you to implement your own supervisor, or, if
> the important thing for you is to *see* the actual error reason, not
> to propagate it, start the SASL application. It adds an event handler to
> error_logger which prints out error information when behaviour processes
> (gen_servers etc) terminates.

  I am already using SASL. The problem is that I need to start some
supervisors dynamically and if a child fails to start, the process 
that tried to start the supervisor can not know the failure reason. So 
I guess that a custom supervisor is the only reasonable way.

-- 
	Samuel



More information about the erlang-questions mailing list