<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Adrian,<br>
<br>
Thank you for the information but unfortunately it's not the cause of my problem. If I add 'user' io:format():<br>
<br>
(myapp@testhost1)6> run_on_all_nodes().<br>
[<27616.12396.0>,<27612.19603.39>,<27615.48.51>]<br>
<br>
(myapp@testhost1)7> [spawn(Node, fun() -> io:format(user, "This runs on ~p~n", [node()]) end) || Node <- nodes()].<br>
[<27616.12397.0>,<27612.19600.39>,<27615.77.51>]<br>
<br>
(myapp@testhost1)8> [spawn(Node, fun() -> io:format("This runs on ~p~n", [node()]) end) || Node <- nodes()].<br>
This runs on myapp@testhost2<br>
This runs on rabbit@testhost1<br>
This runs on rabbit@testhost2<br>
[<27616.12398.0>,<27612.19631.39>,<27615.89.51>]<br>
<br>
It doesn't seem to be I/O channeling problem, it seems that the spawned processes just don't run...<br>
<br>
<br>
Thanks<br>
khitai<br>
<br>
<div class="moz-cite-prefix">On 2016/12/6 17:52, Adrian Roe wrote:<br>
</div>
<blockquote cite="mid:D52E01BF-4F09-4A72-BCA6-2C481716143A@gmail.com" type="cite">
<div class="">This confused me for a while as well…</div>
<div class=""><br class="">
</div>
<div class="">To quote <a moz-do-not-send="true" 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 moz-do-not-send="true" href="http://erlang.org/pipermail/erlang-questions/2008-April/034573.html" class=""></a><a class="moz-txt-link-freetext" href="http://erlang.org/pipermail/erlang-questions/2008-April/034573.html">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 moz-do-not-send="true" href="mailto:khitai.pang@outlook.com" class=""></a><a class="moz-txt-link-abbreviated" href="mailto:khitai.pang@outlook.com">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 moz-do-not-send="true" href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</blockquote>
<br>
</body>
</html>