[erlang-questions] How to find Pids of the children of a supervisor

Vance Shipley vances@REDACTED
Thu Dec 7 14:26:45 CET 2017

On Thu, Dec 7, 2017 at 6:03 PM, Joe Armstrong <erlang@REDACTED> wrote:
> I was asked the following in a direct mail to me:
> "Given two worker processes in a supervision tree, A and B, if A wants
> to message B, how should it obtain the pid of B ?"
> Pretty good question.
> I think the answer is to use supervisor:which_children/1 and to name
> the supervisor and all the children.
> Is the the best way? - does anybody have an example?

Sure, I don't bother to name the supervisor though, pass the pid() down:

Here's an example of a gen_server which locates it's sibling
simple_one_for_one supervisors after initializing:


More information about the erlang-questions mailing list