M
M
Maxim Barulin2015-01-14 18:46:37
Erlang
Maxim Barulin, 2015-01-14 18:46:37

How to add an arbitrary process to gproc?

Good day, Habr!
Is it even possible to add an arbitrary process to gproc? The point is the following. I have two supervisors, the first one starts the second one, but it does it only at the request of supervisor:start_child, since the strategy costs simple_one_for_one. Accordingly, I cannot pass any arguments at the time of launch. The name of the process to be started is calculated by the first supervisor. So it turns out that in the first one I have both the pid and the name, but I cannot register them in the gproc. At least, I did not find api functions for this. Everyone registers the calling process.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-01-14
@Slavenin999

> Respectively to transfer any arguments at the moment of start I cannot.
You can. See start_child: www.erlang.org/doc/man/supervisor.html#start_child-2
> If the case of a simple_one_for_one supervisor, the child specification defined in Module:init/1 will be used and ChildSpec should instead be an arbitrary list of terms List. The child process will then be started by appending List to the existing start function arguments, ie by calling apply(M, F, A++List) where {M,F,A} is the start function defined in the child specification.
Registration in gproc:
gproc:add_local_name(Name) ( https://github.com/uwiger/gproc/blob/master/doc/gp... )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question