[erlang-questions] Question re console io in a distributed computation
Fri Oct 24 22:09:19 CEST 2008
Thank you for your help. I found very useful your observation that
"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."
As a convenience during testing, I was letting the referee process spawn the
player processes, and evreyone wound up having the same group leader. It
was a simple matter to start the player processes independently of the
referee, and then have them register with the referee. After that, console
io went to the right place automatically.
On Fri, Oct 24, 2008 at 2:44 PM, Ulf Wiger (TN/EAB)
> 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
>> 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
> Ulf W
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions