[erlang-questions] Right way to terminate process chain

Alexander Petrovsky <>
Sun Feb 7 14:31:43 CET 2016


Hi!

By example I have the follow chain:

x_sup -> x:start_link ->
               {ok, YPid} = y:start_link(self())
                                   {ok, ZPid} = z:start_link(self())

So, X knows only YPid, Y knows both XPid and ZPid, Z knows only YPid. All
processes are gen_servers. How to terminate the whole chain of the
processes when any process can terminate with 'normal' reason?

I have only two ideas:
- trap_exit, catch EXIT message and terminate
- call gen_server(XPid|YPid|ZPid) from terminate callback in every process,
but it causes 'little temporary' deadlock.


-- 
Петровский Александр / Alexander Petrovsky,

Skype: askjuise
Phone: +7 914 8 820 815
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160207/1a7053c7/attachment.html>


More information about the erlang-questions mailing list