[erlang-questions] Where does io:format's output go? Or where SHOULD it go?

Richard Carlsson <>
Fri Apr 25 09:27:37 CEST 2008

Deryk Barker wrote:
> While setting up a demo for my students to show them how simple it is to 
> load code into another Erlang node and to start processes in another 
> node, when I do this - I start a shell on two systems in two windows, 
> load code from one node to the other and start it - it doesn't matter 
> whether I start the process on the second node via spawn/4 or 
> rpc:call/4, the output, written via io:format by the process on the 
> second node always appears on the first node.
> Is this a feature of the shell?

Not the of shell, but of the IO system as a whole. Every Erlang process
has an associated "group leader" process, that represents the standard-IO
output and input. The group leader is inherited, so new processes get the
same standard output as their parent (this is generally what you want),
but it can be reassigned. So even though your new processes are spawned
on a remote node, their standard IO is still sent to the original group
leader on the initial node (a great example of transparency, actually).

You could make a neat demonstration by letting the remote process read a
local file (i.e. on the remote node) and print the contents on stdout,
which will then show up on the caller's terminal. To show some activity
on the remote node, you can explicitly write to 'user' instead of stdout,
as in `io:fwrite(user,"the result is ~w\n",[X])'.


More information about the erlang-questions mailing list