Distributed spawn-linking.

Chandrashekhar Mullaparthi <>
Mon Aug 8 19:35:20 CEST 2005

On 8 Aug 2005, at 17:37, Javier París Fernández wrote:

> Hi,
> On Mon, Aug 08, 2005 at 07:14:15PM +0300, Alex Arnon wrote:
>> Thank you, but this does not answer my question, which is specifically
>> about the behaviour of spawn(). I shall reword:
>> - Is spawn(Node, ...) a synchronous operation? I.e. does the spawning
>> process wait for the target node to acknowledge and assign the PID
>> before returning?
>> - If not, does Erlang handle the original example? And if it does, 
>> how?
> Well, as the spawn call returns the pid of the created process, it has
> to be syncrhonous.

I don't think so. This is what the manpage says.

        spawn(Node, Module, Function, ArgumentList)

               Works like spawn/3, with  the  exception  that  the  
process  is
               spawned  at  Node.  If  Node  does  not  exist, a useless 
Pid is

               Failure: badarg if Node, Module, or Function are not  
atoms,  or
               ArgumentList is not a list.

        spawn_link(Node, Module, Function, ArgumentList)

               Works  like  spawn_link/3, except that the process is 
spawned at
               Node. If an attempt is made to spawn a process on a  node 
               does  not  exist,  a useless Pid is returned, and an EXIT 
               will be received.

And if you look in kernel/src/erlang.erl you'll see exactly how a spawn 
on a remote node is implemented. In short, you can't rely on the output 
of spawn/4 or spawn_link/4 to "guarantee" that a process has been 
spawned on the remote node. You'll need some application level protocol 
to establish this.


More information about the erlang-questions mailing list