[erlang-questions] OTP Supervisor Question

Zoltan Lajos Kis <>
Mon Jan 4 13:29:27 CET 2010


> El Lunes, 4 de Enero de 2010 04:12:40 Chandru escribiĂł:
>> 2010/1/4 Jayson Vantuyl <>
>>
>> > If I'm an OTP-style process (say, a gen_server), and I want to know
>> who my
>> > parent is (say, a supervisor), is this possible using any API, or do I
>> need
>> > to pass in the Parent explicitly?  Is using supervisor:get_child a
>> good way
>> > to find a process's sibling?  Would it be better to start a single
>> > gen_server and have it use normal, linked processes?
>> >
>>
>> I think using supervisor:which_children(Sup_ref)  is quite reasonable.
>> But
>> for this, you'll have to store the process id of the supervisor in all
>> the
>> supervised processes.
>>
>>
>> >
>> > I have a certain automaton that is represented as a group of three
>> > processes.  These processes coordinate and there may be multiple
>> automata on
>> > a single node.  I want to put them under a single supervisor, but I'm
>> > struggling a bit to get them to all know each other's PIds without
>> adding
>> > code to the supervisor (which is bad, right?) and without having to
>> locally
>> > register them (which would prevent multiple automata per node).
>> >
>>
>> As far as I understand, you'll need a two level supervision tree. One
>> supervisor supervising each set of three processes, and those
>> supervisors in
>> turn under a top level supervisor. That way, when any of a set of three
>> processes invoke supervisor:which_children(Sup_ref) on its supervisor,
>> it'll
>> only see that set and nothing else.
>>
>> Chandru
>>
> Try aplication docs, maybe thereis some function to traverse aplication
> supervisors...
>
>
> --
> Este correo no tiene dibujos. Las formas extraĂąas en la pantalla son
> letras.
> __________________________________________
>
> Clist UAH a.k.a Angel
> __________________________________________
> El Universo es una de esas cosas que sucede de vez en cuando...
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>
>

Something similar is implemented in process_info:do_get_processes/3 in
appmon.



More information about the erlang-questions mailing list