mwt
mwt

Reputation: 135

erlang: anything like name_for_pid()?

Is there a way to get a registered name if you have a PID?

Upvotes: 6

Views: 1892

Answers (1)

archaelus
archaelus

Reputation: 7129

I'm assuming you want this for some kind of debugging/introspection purpose and not for general use in your code:

erlang:process_info(Pid, registered_name).

Gives you [] if the process doesn't have a locally registered name, and {registered_name, Name} if there is one.

Upvotes: 6

Related Questions