<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">This confused me for a while as well…</div><div class=""><br class=""></div><div class="">To quote <a href="http://erlang.org/doc/man/erlang.html" class="">http://erlang.org/doc/man/erlang.html</a></div><div class=""><br class=""></div><div class=""><p style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: medium; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""><span class="bold_code" style="font-family: Courier, monospace; font-weight: bold;">group_leader() -> pid()</span><br class=""></p><div class="REFBODY" style="margin-left: 13mm; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: medium; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"><div class=""><br class="webkit-block-placeholder"></div><p class="">Returns the process identifier of the group leader for the process evaluating the function.</p><p class="">Every process is a member of some process group and all groups have a <strong class="">group leader</strong>. All I/O from the group is channeled to the group leader. When a new process is spawned, it gets the same group leader as the spawning process. Initially, at system startup, <span class="code" style="font-family: Courier, monospace;">init</span> is both its own group leader and the group leader of all processes.</p></div></div><div class="">There’s a helpful post here <a href="http://erlang.org/pipermail/erlang-questions/2008-April/034573.html" class="">http://erlang.org/pipermail/erlang-questions/2008-April/034573.html</a> that talks about exactly what you are seeing.</div><div class=""><br class=""></div><div class="">If you change the </div><div class=""><span class="Apple-tab-span" style="white-space:pre">       </span>io:format("This runs on ~p~n", [node()]) </div><div class="">to </div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>io:format(user, "This runs on ~p~n", [node()])</div><div class=""><br class=""></div><div class="">I strongly suspect you will see the output you were expecting…</div><div class=""><br class=""></div><div class="">Adrian</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 6 Dec 2016, at 09:34, Khitai Pang <<a href="mailto:khitai.pang@outlook.com" class="">khitai.pang@outlook.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi,<br class=""><br class="">I have the following function in user_default.erl:<br class=""><br class="">run_on_all_nodes() -><br class="">     [spawn(Node, fun() -><br class="">                          io:format("This runs on ~p~n", [node()])<br class="">                  end) || Node <- nodes()].<br class=""><br class="">When I run this function, processes can be spawned on remote nodes but <br class="">it seems that they don't run:<br class=""><br class="">(myapp@testhost1)1> nodes().<br class="">[myapp@testhost2,rabbit@testhost1,rabbit@testhost2]<br class=""><br class="">(myapp@testhost1)2> run_on_all_nodes().<br class="">[<27616.12336.0>,<27612.15341.39>,<27615.22399.50>]<br class=""><br class="">If I manually run the spawn command in the attached shell, it all works <br class="">fine:<br class=""><br class="">(myapp@testhost1)3> [spawn(Node, fun() -> io:format("This runs on ~p~n", <br class="">[node()]) end) || Node <- nodes()].<br class="">This runs on myapp@testhost2<br class="">This runs on rabbit@testhost1<br class="">This runs on rabbit@testhost2<br class="">[<27616.12339.0>,<27612.15569.39>,<27615.22640.50>]<br class=""><br class=""><br class="">Any idea?<br class=""><br class=""><br class="">Thanks<br class="">Khitai<br class="">_______________________________________________<br class="">erlang-questions mailing list<br class=""><a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></div></blockquote></div><br class=""></div></body></html>