[erlang-questions] Question re console io in a distributed computation

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Fri Oct 24 20:44:59 CEST 2008


David Cabana skrev:
 >
> The messages flow correctly, but all the terminal 
> io happens in
> a single console, the one associated with the referee node.
> 
> My question is how to get player output written to the console of the 
> corresponding
> player node? 

Use io:format(user, Fmt, Args)

Alternatively, set the group leader of the process to some
local process - e.g. the group leader of net_kernel
(found by calling process_info(whereis(net_kernel),group_leader)).

The group leader is the process that's handed all io messages.
The rpc server deliberately sets the group leader of an rpc
handler process to that of the caller on the originating node,
since the remote node may not always have a tty to print to.
When spawning, the group leader of the spawned process will
be inherited from the parent. If you spawn a process on
another node, it will still have the same group leader as
the parent.

The BIF group_leader(Pid,New_group_leader_pid) sets a new
leader.

BR,
Ulf W



More information about the erlang-questions mailing list