<div dir="ltr"><div>No, there is not any difference. Both versions of code is compiled exactly same:</div><div><br>fun1(Socket,Mod, Fun, Args) -></div><div> Pid = erlang:spawn(Mod, Fun, Args),</div><div> gen_tcp:controlling_process(Socket,Pid).</div><div><br></div><div>fun2(Socket,Mod, Fun, Args) -></div><div> gen_tcp:controlling_process(Socket,erlang:spawn(Mod, Fun, Args)).</div><div><br></div><div>Then you can compile it with 'S' and get "assembler":</div><div><br></div><div><div>{function, fun1, 4, 2}.</div><div> {label,1}.</div><div> {line,[{location,"test2.erl",5}]}.</div><div> {func_info,{atom,test2},{atom,fun1},4}.</div><div> {label,2}.</div><div> {allocate,1,4}.</div><div> {move,{x,0},{y,0}}.</div><div> {move,{x,1},{x,0}}.</div><div> {move,{x,2},{x,1}}.</div><div> {move,{x,3},{x,2}}.</div><div> {line,[{location,"test2.erl",6}]}.</div><div> {call_ext,3,{extfunc,erlang,spawn,3}}.</div><div> {move,{x,0},{x,1}}.</div><div> {move,{y,0},{x,0}}.</div><div> {line,[{location,"test2.erl",7}]}.</div><div> {call_ext_last,2,{extfunc,gen_tcp,controlling_process,2},1}.</div><div><br></div><div><br></div><div>{function, fun2, 4, 4}.</div><div> {label,3}.</div><div> {line,[{location,"test2.erl",9}]}.</div><div> {func_info,{atom,test2},{atom,fun2},4}.</div><div> {label,4}.</div><div> {allocate,1,4}.</div><div> {move,{x,0},{y,0}}.</div><div> {move,{x,1},{x,0}}.</div><div> {move,{x,2},{x,1}}.</div><div> {move,{x,3},{x,2}}.</div><div> {line,[{location,"test2.erl",10}]}.</div><div> {call_ext,3,{extfunc,erlang,spawn,3}}.</div><div> {move,{x,0},{x,1}}.</div><div> {move,{y,0},{x,0}}.</div><div> {line,[{location,"test2.erl",10}]}.</div><div> {call_ext_last,2,{extfunc,gen_tcp,controlling_process,2},1}.</div><div><br></div></div><div>As you can see, both functions are exactly same. Why should be there any difference.</div><div><br></div><div>Hynek Vychodil</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 1, 2014 at 11:34 AM, Gadi Srebnik <span dir="ltr"><<a href="mailto:gadi@rounds.com" target="_blank">gadi@rounds.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all, my first question here.<div><br></div><div>How safe it is to use controlling_process after spawn? I am using additional gen_tcp:controlling_process inside the Mod:Fun itself after few additional commands. Is it possible that process will not be owner by then?</div><div><span><br></span></div><div><span><br></span></div><div><span>Pid</span> = erlang:spawn(<span>Mod</span>, Fun, Args),<br></div><div>
<p><span> </span><span> </span>gen_tcp:controlling_process(<span>Socket</span>,<span>Pid</span>),</p></div><div><br></div><div>Is one-liner safer? </div><div><br></div><div>gen_tcp:controlling_process(<span>Socket</span>,erlang:spawn(<span>Mod</span>, Fun, Args)),<br></div><div><br></div><div><br></div><div>Thanks, </div><span class="HOEnZb"><font color="#888888"><div>Gadi<br>
<div><br></div></div></font></span></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>