Exercise 6-3 module not available

13 views
Skip to first unread message

kohai

unread,
Aug 10, 2010, 4:06:31 PM8/10/10
to Erlang Programming
Dear All,

I have a question about the second feature, in the book I read:

What happens if the supervisor tries to spawn a child whose module is
not available?
The process will crash, and its EXIT signal is sent to the supervisor
that immediately
restarts it. Our supervisor does not handle the infinite restart case.
To
avoid this case, use a counter that will restart a child a maximum of
five times per
minute, removing the child from the child list and printing an error
message when
this threshold is reached.

Well I tried to call the start_link function with a list of one child
with a module name that doesn't exist and what happen is that no EXIT
signal was sent but the second branch of case statement was executed:

start_children([{Id,M,F,A,T}| ChildSpecList]) ->
case (catch apply(M,F,A)) of
{ok, Pid} ->
io:format("info: start Ok for Pid=~p.~n", [Pid]),
[{Pid, {Id,M,F,A,T,[]}}|start_children(ChildSpecList)];
_ ->
io:format("info: start KO for Function=~p.~n", [F]),
start_children(ChildSpecList)
end.

2> my_sup_i3:start_link(supervisor,[{1,echo,start2,[],transient}]).
ok
info: start KO for Function=start2.
3>

Maybe I didn't understand the point, can somebody clear this point ?

Thanks
Reply all
Reply to author
Forward
0 new messages