<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; "><div><br></div><div>It shouldn't be the need for atomicity as much as a convenience and - in the case of remote spawn - an optimization.</div><div><br></div><div>On R15B, it works as you'd expect:</div><div><br></div><div><div>Erlang R15B (erts-5.9) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]</div><div><br></div><div>Eshell V5.9 (abort with ^G)</div><div>1> spawn_opt(fun() -> io:fwrite("hi~n",[]) end, [monitor]).</div><div>hi</div><div>{<0.33.0>,#Ref<0.0.0.33>}</div><div>2> flush().</div><div>Shell got {'DOWN',#Ref<0.0.0.33>,process,<0.33.0>,normal}</div><div>ok</div></div><div><br></div><div>Same on R16B, as far as I can tell.</div><div><br></div><div>BR,</div><div>Ulf W</div><br><div><div>On 29 Jul 2013, at 13:54, Michał Ptaszek <<a href="mailto:erlang@ptaszek.net">erlang@ptaszek.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">I'm not sure if spawn and monitor have to be atomic though. If we set up a monitor on non-existing/exiting process 'DOWN' message is going to be delivered to the caller anyway ("A 'DOWN' message will be sent to the monitoring process if Item dies, if Item does not exist, or if the connection is lost to the node which Item resides on.", <a href="http://www.erlang.org/doc/man/erlang.html#monitor-2">http://www.erlang.org/doc/man/erlang.html#monitor-2</a>). <div>
<br></div><div>It's not a big deal for me to spin up a monitor on my own, however it would be good to know if I miss something or should code/documentation be fixed.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Jul 27, 2013 at 1:03 PM, Motiejus Jakštys <span dir="ltr"><<a href="mailto:desired.mta@gmail.com" target="_blank">desired.mta@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Sat, Jul 27, 2013 at 1:05 PM, Michał Ptaszek <<a href="mailto:erlang@ptaszek.net">erlang@ptaszek.net</a>> wrote:<br>
> Hey,<br>
><br>
> What is the reason for not allowing to pass 'monitor' option to processes<br>
> spawned by erlang:spawn_opt/5?<br>
><br>
> The code inside of erlang.erl states:<br>
><br>
> case lists:member(monitor, O) of<br>
> false -> ok;<br>
> true -> erlang:error(badarg, [N, M, F, A, O])<br>
> end,<br>
><br>
> However the documentation does not clarify anything.<br>
> Setting up a monitor on the returned pid right after spawn works fine<br>
> though.<br>
<br>
</div></div>I guess the reason is that there is no way in Erlang to atomically<br>
spawn and monitor the pid on another node. Though it's a bit strange<br>
that [link] works on remote nodes, but [monitor] doesn't. Anyone care<br>
to explain why?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Motiejus Jakštys<br>
</font></span></blockquote></div><br></div>
_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div><div>Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.</div><div><a href="http://feuerlabs.com">http://feuerlabs.com</a></div></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>