<div>
Hi,<div><br></div><div>I have the same question before and you can see my question here: <a href="http://stackoverflow.com/questions/16693922/simple-one-for-one-can-only-be-terminated-if-appointed-shutdown-strategy-to-brut" style="color: rgb(0, 106, 227); "></a><a href="http://stackoverflow.com/questions/16693922/simple-one-for-one-can-only-be-terminated-if-appointed-shutdown-strategy-to-brut">http://stackoverflow.com/questions/16693922/simple-one-for-one-can-only-be-terminated-if-appointed-shutdown-strategy-to-brut</a>.</div><div><br></div><div>As you've described, I created an example on github: <a href="https://github.com/goofansu/sofo-example">https://github.com/goofansu/sofo-example</a>, and can print "terminate" as expected.</div><div><br></div><div>My operations like following:</div><div><br></div><div><div><font color="#636363">$ erl -pa ebin -s myapp</font></div><div><font color="#636363">Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [kernel-poll:false]</font></div><div><font color="#636363"><br></font></div><div><font color="#636363">Eshell V5.9.1 (abort with ^G)</font></div><div><font color="#636363">1> {ok, ChildPid} = myapp_sup:start_child().</font></div><div><font color="#636363">{ok,<0.37.0>}</font></div><div><font color="#636363">2> ChildPid ! stop.</font></div><div><font color="#636363">terminate</font></div><div><font color="#636363">stop</font></div><div><font color="#636363">3></font></div></div><div><br></div><div>If you use myapp_sup:stop_child(ChildPid). It will terminate directly.</div>
</div>
<div><div><br></div><div>-- </div><div>Kind Regards</div><div>goofansu</div><div><br></div></div>
<p style="color: #A0A0A8;">在 2013年7月11日星期四,下午2:41,Bin Wang 写道:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><div>Hi,</div><div><br></div><div>I found my terminate in gen_server is not been called in this</div><div>situation, did I miss something?</div><div><br></div><div>Part of the code is:</div><div><br></div><div>handle_info(stop, State) -></div><div> {stop, normal, State}.</div><div><br></div><div>terminate(_, _) -></div><div> io:format(user, "termiate~n", []).</div><div><br></div><div>And I have set process_flag(trap_exit, true) in "init", and this</div><div>gen_server is under a supervisor tree. It is a simple_one_for_one</div><div>supervisor and the spec is like this, "client" here is the module</div><div>name:</div><div><br></div><div> {ok, {{simple_one_for_one, 3, 10}, [{</div><div> client,</div><div> {client, start, []},</div><div> transient,</div><div> 10000,</div><div> worker,</div><div> [client]</div><div> }</div><div> ]}}.</div><div><br></div><div>When I send some info with stop to the gen_server, it did stop, but</div><div>the terminate function is not called. Anybody have some ideas? Thanks!</div><div>_______________________________________________</div><div>erlang-questions mailing list</div><div><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a></div><div><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></div></div></div></span>
</blockquote>
<div>
<br>
</div>