<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 class="Apple-tab-span" style="white-space: pre;">   </span>process_flag(trap_exit, true),</div><div><span class="Apple-tab-span" style="white-space: pre;">     </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 class="Apple-tab-span" style="white-space: pre;">  </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 class="Apple-tab-span" style="white-space: pre;">        </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 class="Apple-tab-span" style="white-space: pre;">  </span>%process_flag(trap_exit, true),</div><div><span class="Apple-tab-span" style="white-space: pre;">    </span>%gen_server:start({local, my_bank2}, my_bank2, [], []),</div><div><span class="Apple-tab-span" style="white-space: pre;">    </span>io:format("=====start===== my_bank ~n"),</div><div><span class="Apple-tab-span" style="white-space: pre;"> </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 left-pos="0|12" right-pos="0|12" space="" class="high-light-bg" style="border-radius: 5px; cursor: pointer; color: rgb(51, 51, 51); font-family: arial; font-size: 14px; line-height: 22px; background: yellow;">This problem</span><span left-pos="13|19" right-pos="13|19" space="0| " class="" style="color: rgb(51, 51, 51); font-family: arial; font-size: 14px; line-height: 22px;"> has troubled me for a long time</span><span left-pos="32|3" right-pos="32|3" space="" class="" style="color: rgb(51, 51, 51); font-family: arial; font-size: 14px; line-height: 22px;">,</span><span left-pos="35|6" right-pos="35|6" space="0| " class="" style="color: rgb(51, 51, 51); font-family: arial; font-size: 14px; line-height: 22px;"> very much</span><span left-pos="41|18" right-pos="41|18" space="0| " class="" 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 id="netease_mail_footer"></span></span>