[erlang-questions] Accessing sibling processes in a supervisor.

Karolis Petrauskas k.petrauskas@REDACTED
Fri Dec 21 02:24:29 CET 2012


Hi,

I have a question regarding an example [1] in LYSE. The example
proposes a supervision scheme for a server-worker like processes. I
have used this scheme a lot (I learnt Erlang from this book mainly),
but now I'm in doubt. Is the proposed way of accessing a sibling
process (access worker_sup from ppool_serv, see [1]) is the correct
one? How will the ppool_serv get a PID of the worker_sup after a crash
and restart? As I understand, if one of the processes will crash, both
processes will be restarted and the server should get an error while
starting the worker_sup again (the corresponding child already
exists):

    handle_info({start_worker_supervisor, Sup, MFA}, S = #state{}) ->
        {ok, Pid} = supervisor:start_child(Sup, ?SPEC(MFA)),        %
Will this work after restart?

Or maybe I missed the point? I am aware of some other ways of getting
processes to know each other [2], but I would like to get your
comments on this example. Other schemes for implementing communication
of anonymous sibling processes (in the supervision tree) would be
interesting also.

[1] http://learnyousomeerlang.com/building-applications-with-otp#implementing-the-supervisors
[2] http://erlang.2086793.n4.nabble.com/supervisor-children-s-pid-td3530959.html#a3531973

Best regards,
Karolis Petrauskas



More information about the erlang-questions mailing list