[erlang-questions] displaying the globally, registered name in Observer

James Rosenblum jrosenblum@REDACTED
Tue Dec 4 18:29:36 CET 2012

I am writing a distributed application and could not seem to find a way to get Observer's Applications pane to show the registered name of a process when that process is globally registered (as in gen_server:start_link({global, Name}, ?MODULE, [],[])).

I also couldn't find a global method which returned a registered name given a pid. So, I added a function go the global module

pid_2_name(Pid) ->
    case ets:lookup(global_pid_names, Pid) of
[{Pid, Name}] -> 
    if node(Pid) == node() ->
    case is_process_alive(Pid) of
true -> Name;
false -> undefined
       true ->
[] -> undefined

and then I modified appmon_info and observer_procinfo to make use of this function when process_info failed to return a {registered_info, _} tuple. I did this sort of thing:

 case process_info(P, registered_name) of
{registered_name, Name} -> atom_to_list(Name);
_ ->
    case global:pid_2_name(P) of
undefined -> pid_to_list(P);
Name -> "*" ++ atom_to_list(Name)

So was this a totally unsafe and / or  unnecessary thing to do; or, is this for the most part an okay thing to do?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121204/b8308e5d/attachment.htm>

More information about the erlang-questions mailing list