Is there a direct way to retrieve the registered name
associated with a pid()
? Or do I have to go through the registered()
names and do a whereis()
on each element of the list to find it?
views:
163answers:
1
+4
A:
Check out erlang:process_info/2 and this ItemSpec:
{registered_name, Atom}
Atom is the registered name of the process. If the process has no registered name, this tuple is not present in the list.
PS. Why do you want this reverse mapping? Is it just for interactive debugging?
Christian
2009-12-18 16:12:41
@Christian: I have a "message bus" where I keep track of the "subscribers". I do this via their "registered name" so when a server restarts (new pid()), I don't loose all its config -> lower down-time
jldupont
2009-12-18 16:15:19