[erlang-questions] Process unexpectedly locks up
Doug Edmunds (gmail)
dougedmunds@REDACTED
Tue May 4 16:42:59 CEST 2010
Hello Sam,
Your suggestion for using a {down, X} handler works. Thank you!
Modify the code this way:
1. Remove the original 'down' handler from the me_loop.
2. Replace with these two handlers:
--------------
down ->
case length(K) of
0 -> io:format("--No kids~n");
1 -> [Head |_] = K,
Head ! {self(), info_request};
_ -> Out = indexlist(1, K, []),
ok = io:format("Use me ! {down, Integer} to select: ~p~n",
[Out])
end,
NM = M, NK = K, NP = P;
{down, Input} -> % use after down displays the choices
case is_integer(Input) of
true ->
Out = indexlist(1, K, []),
Pick = pick_pid(Out,Input),
case is_pid(Pick) of
true ->
Pick ! {self(), info_request};
_ -> io:format("That number is not on the list~n")
end;
_ ->
io:format("Must enter an integer~n")
end,
NM = M, NK = K, NP = P;
------------
--- Doug Edmunds
On 5/3/2010 10:41 PM, Sam Bobroff wrote:
> * add a handler for a {down, X} message that takes choice X as if it had
> been returned from get_user_input() in the old code.
More information about the erlang-questions
mailing list