[erlang-questions] Registered processes:

Sean Hinde <>
Sun Mar 25 15:27:51 CEST 2007


On 25 Mar 2007, at 13:27, Fredrik Hoback wrote:

> Hi, I'm new to erlang but I have some questions regarding process  
> registration.
> I have these 2 modules that I want to send messages between with Pid !
> Msg for example. As I start my first module a gen_server (alpha) from
> the shell which spawns away with spawn(?MODULE,start,[]). It sits
> around waiting for incoming messages. Then also from the same shell I
> start my other module (beta) which begins with register(?MODULE,
> self()). Now when the gen_server receives a message that I want to
> forward to my second module (beta). But I don't get any message, it
> seems that it gets lost on the way. Is there a problem that the beta
> module does a registration after the fact that alpha has already
> started, because I use "beta ! Msg" to send the message from alpha to
> beta.

One thing to check is that the processes are still running. Using  
spawn to start the process doesn't give any indication that a process  
has died.

A nice way to debug this is first to make sure sasl is running  -  
application:sart(sasl).

Then if you start the gen_servers using the gen_server:start.. API  
you will see if the server has died.

And, to answer your specific question, it does not matter when a  
process is registered. Once it is registered all other processes in  
the same node get access to the name mapping.

Sean






More information about the erlang-questions mailing list