<div dir="ltr"><div>Steven,<br><br></div>That isn't supported by the supervisor API. You'll need to create a child process beneath the supervisor (using gen_server for example) and handle the init/1 and terminate/2 behaviour there.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 24 April 2013 11:49, Seven Du <span dir="ltr"><<a href="mailto:dujinfang@gmail.com" target="_blank">dujinfang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
Thanks Vance. Maybe I didn't made clear, I want a terminate callback in the -behaviour(supervisor).</div><div class="im HOEnZb">
<div><div><br></div><div>-- </div><div>Seven Du</div><div><span style="font-size:10pt"><a href="http://www.freeswitch.org.cn" target="_blank">http://www.freeswitch.org.cn</a></span></div><div><a href="http://about.me/dujinfang" target="_blank">http://about.me/dujinfang</a></div>
<div><div><a href="http://www.dujinfang.com" target="_blank">http://www.dujinfang.com</a></div></div><div><br></div><div>Sent with <a href="http://www.sparrowmailapp.com/?sig" target="_blank">Sparrow</a></div><div><br></div>
</div>
</div><div class="HOEnZb"><div class="h5"><p style="color:#a0a0a8">On Saturday, April 20, 2013 at 5:34 PM, Vance Shipley wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
<span><div><div><p dir="ltr">To get the terminate/1 callback in a gen_server or gen_fsm behaviour module what you would do is to set the process flag to trap exits in your init/1 callback.</p>
<div>On Apr 20, 2013 4:34 PM, "Seven Du" <<a href="mailto:dujinfang@gmail.com" target="_blank">dujinfang@gmail.com</a>> wrote:<br type="attribution"><blockquote type="cite"><div>
<div>
Hi,
</div><div><br></div><div>I'd like to know is it possible to have a terminate callback that clean up things when the supervisor stops?</div><div><br></div><div>Specifically I want to write an application which starts a supervisor, and add a handler to some existing gen_event by calling gen_event:add_handler() on init(), and I want to call gen_event:remove_handler() when the application is stop. Is there an easy way to do it?</div>
<div><br></div><div>Thanks </div>
<div><div><br></div><div>-- </div><div>Seven Du</div><div><span style="font-size:10pt"><a href="http://www.freeswitch.org.cn" target="_blank">http://www.freeswitch.org.cn</a></span></div><div><a href="http://about.me/dujinfang" target="_blank">http://about.me/dujinfang</a></div>
<div><div><a href="http://www.dujinfang.com" target="_blank">http://www.dujinfang.com</a></div></div><div><br></div><div>Sent with <a href="http://www.sparrowmailapp.com/?sig" target="_blank">Sparrow</a></div><div><br></div>
</div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">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></div></blockquote></div>
</div></div></span>
</blockquote>
<div>
<br>
</div>
</div></div><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><br></div>