[erlang-questions] Why is the spawn_link not working?

Yves S. Garret <>
Tue Jan 14 02:26:22 CET 2014


Hmm... here is my updated code, but the exit that comes via a link does not
seem to get trapped!
http://bin.cakephp.org/view/936550339

This is what happens:
http://bin.cakephp.org/view/554367077


On Sun, Jan 12, 2014 at 7:48 PM, Bob Ippolito <> wrote:

> When two processes are linked, failures (abnormal exits) propagate from
> one to the other, ensuring that both die. This is not done by way of
> messages, but by an exit signal. These EXIT messages are only sent to
> processes that are trapping exits. See
> http://www.erlang.org/doc/reference_manual/processes.html#id83186 and
> refer to "Receiving Exit Signals".
>
> In your case, the code in one process fails, which causes the other
> process to fail, so it can't print anything because there is no more
> process and it never received an exit message. A solution to this problem
> would be to use the trap_exit process flag (as is the case with
> supervisors), or use a monitor instead of a link.
>
> -bob
>
>
>
> On Sun, Jan 12, 2014 at 4:36 PM, Yves S. Garret <
> > wrote:
>
>> Hello,
>>
>> I've recently created the following two modules from a book:
>> http://bin.cakephp.org/view/1356260281
>> http://bin.cakephp.org/view/13533081
>>
>> Now, when I send Pid ! {moon, asdf}. I get the following output:
>> 39> Pid ! {moon, w}.
>> Received the input and sending now.
>> Received the input to drop.
>> {moon,w}
>>
>> =ERROR REPORT==== 12-Jan-2014::19:31:38 ===
>> Error in process <0.162.0> with exit value:
>> {badarith,[{drop,fall_velocity,2,[{file,"drop.erl"},{line,27}]},{drop,drop,0,[{file,"drop.erl"},{line,17}]}]}
>>
>> Why am I not seeing this line run?
>> io:format("FAILURE: ~p died because of ~p.~n~n", [Pid, Reason]);
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140113/7b80a42b/attachment.html>


More information about the erlang-questions mailing list