[erlang-questions] Registered names and pids

Matthias Lang <>
Wed May 14 08:08:01 CEST 2008


Deryk Barker writes:
 > Maybe I shouldn't need to know this, but I can't find any obvious way: 
 > is it possible, given the name of a registered process, to find its pid: 
 > a) on the same nod b) on another node?

It sounds like you haven't stumbled across erlang:whereis/1 yet:

  1> Pid = spawn(fun() -> timer:sleep(12000) end).
  <0.34.0>
  2> register(name, Pid).
  true
  3> whereis(name).
  <0.34.0>

It also handles part b.

The 'erlang' module contains lots of useful things (and quite a few
obscure ones too), so it's worth taking a look through:

  http://erlang.org/doc/man/erlang.html

Matt



More information about the erlang-questions mailing list