<p>Try removing the process_flag(trap_exit, true) from the supervisor. I don't know if that is the problem. I have no idea what trapping exits in a supervisor does, but it looks wrong :-)</p>
<p>Regards<br>
Robby</p>
<div class="gmail_quote">On Apr 15, 2015 3:17 PM, "谈广云" <<a href="mailto:fw339tgy@126.com">fw339tgy@126.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="font-size:13.63636302948px;line-height:21.6363620758057px">hi joe,</div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">when i use erlang laguage , i meet a problem.</div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">i use supervisor to manage the child process.</div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">test module is <span style="font-size:13.63636302948px;line-height:21.6363620758057px">supervisor</span><span style="font-size:13.63636302948px;line-height:21.6363620758057px"> , the child is my_bank moudle  is gen_server's callback .</span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px">the code is :</span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px">%%%%test module </span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><div>-module(test).</div><div>-behaviour(supervisor).</div><div><br></div><div>%% ====================================================================</div><div>%% API functions</div><div>%% ====================================================================</div><div>%% Supervisor callbacks</div><div>-export([init/1]).</div><div><br></div><div>-export([start_link/0,start_child/0]).</div><div><br></div><div>%% ====================================================================</div><div>%% Internal functions</div><div>%% ====================================================================</div><div><br></div><div>init([]) -></div><div><span style="white-space:pre-wrap">       </span>process_flag(trap_exit, true),</div><div><span style="white-space:pre-wrap">   </span>Poker = {my_bank, {my_bank, start, []}, permanent, brutal_kill, worker, [my_bank]},</div><div>  {ok, {{one_for_one, 5, 10}, [Poker]}}.</div><div><br></div><div>start_link() -></div><div><span style="white-space:pre-wrap">    </span>supervisor:start_link({local, ?MODULE}, ?MODULE, []).</div></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">%%%%% =============</div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">%%%% my_bank module </div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><div>-module(my_bank).</div><div><br></div><div>-behaviour(gen_server).</div><div>-export([start/0]).</div><div>%% gen_server callbacks</div><div>-export([init/1, handle_call/3, handle_cast/2, handle_info/2,</div><div><span style="white-space:pre-wrap">      </span> terminate/2, code_change/3]).</div><div>-compile(export_all).</div><div>-define(SERVER, ?MODULE). </div><div><br></div><div>start() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).</div><div>stop()  -> gen_server:call(?MODULE, stop).</div><div><br></div><div>new_account(Who)      -> gen_server:call(?MODULE, {new, Who}).</div><div>deposit(Who, Amount)  -> gen_server:call(?MODULE, {add, Who, Amount}).</div><div>withdraw(Who, Amount) -> gen_server:call(?MODULE, {remove, Who, Amount}).</div><div><br></div><div>init([]) -> </div><div><span style="white-space:pre-wrap">        </span>%process_flag(trap_exit, true),</div><div><span style="white-space:pre-wrap">  </span>%gen_server:start({local, my_bank2}, my_bank2, [], []),</div><div><span style="white-space:pre-wrap">  </span>io:format("=====start===== my_bank ~n"),</div><div><span style="white-space:pre-wrap">       </span>{ok, ets:new(?MODULE,[])}.</div></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">%%%%%%</div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">i call gen_server:call(my_bank,{new2,inzaghi}).</div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px">gen_server:call(my_bank,{new,inzaghi}) is right .</span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">the my_bank will occur a error "<span style="font-size:13.63636302948px;line-height:21.6363620758057px">function_clause</span><span style="font-size:14px;line-height:1.7">".</span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">when the my_bank process <span style="font-size:13.63636302948px;line-height:21.6363620758057px">occur </span>' function_clause' error, the <span style="font-size:13.63636302948px;line-height:21.6363620758057px">supervisor can not restat the my_bank process , and quit with no error.</span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><span style="border-radius:5px;color:rgb(51,51,51);font-family:arial;font-size:14px;line-height:22px;background:yellow">This problem</span><span style="color:rgb(51,51,51);font-family:arial;font-size:14px;line-height:22px"> has troubled me for a long time</span><span style="color:rgb(51,51,51);font-family:arial;font-size:14px;line-height:22px">,</span><span style="color:rgb(51,51,51);font-family:arial;font-size:14px;line-height:22px"> very much</span><span style="color:rgb(51,51,51);font-family:arial;font-size:14px;line-height:22px"> look forward to your reply.</span></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px"><br></div><div style="font-size:13.63636302948px;line-height:21.6363620758057px">thanks.</div></div><br><br><span title="neteasefooter"><span></span></span><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div>