[erlang-questions] erlang:process_info for global processes

Steve Vinoski vinoski@REDACTED
Sat Sep 19 18:49:15 CEST 2015

On Sat, Sep 19, 2015 at 11:01 AM, Adam Kövári <kovariadam@REDACTED> wrote:

> Hello
> I noticed erlang:process_info(<PID of a global process>, registered_name)
> returns []. Is this expected? What is the reason this doesn’t work for
> globally registered processes?

The process_info call returns local process information. The global process
support is entirely separate.

> Is there a built in function which would work with global processes?
> Example:
> 6> global:registered_names().
> [test_dumb1,...]
> 7>
> 7> Pid = global:whereis_name(test_dumb1).
> <0.306.0>
> 8> erlang:process_info(Pid, registered_name).
> []

I don't see an API function for what you want, but here's a hack to get it:

9> ets:lookup(global_pid_names, Pid).

But this reaches into the internals of the global module and so isn't the
best thing to do. Perhaps the global module needs a new lookup-by-pid or
process_info exported function. Or then again, maybe there's a good reason
it's not provided.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150919/203dfbe9/attachment.htm>

More information about the erlang-questions mailing list