<div dir="ltr"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Robert Virding</b> <span dir="ltr"><<a href="mailto:rvirding@gmail.com">rvirding@gmail.com</a>></span><br>Date: 6 October 2015 at 18:46<br>Subject: Re: [erlang-questions] Strange behaviour of exit(kill)<br>To: zxq9 <<a href="mailto:zxq9@zxq9.com">zxq9@zxq9.com</a>><br>Cc: erlang-questions <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br><br><br><div dir="ltr"><div><div><div>It's all about signals and not messages. Sending a message to a process should *NEVER* by default kill it even if it has the same format as an 'EXIT' message. NEVER!. A signal is converted to a message when it arrives at a process which is trapping exits unless it is the 'kill' which is untrappable and the process always dies.<br><br></div>Explicitly sending the SIGNAL with exit(Pid, kill) should unconditionally kill the process as should dying with the reason 'kill' in exit(kill) which also sends the SIGNAL 'kill'. In both cases the process receives the SIGNAL 'kill', as shown in my example, but in one case it is trappable and in the other it is untrappable.<br><br></div>My point is that the *same* signal results in different behaviour depending on how it was sent. That's incocnsistent.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888">Robert<br><br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 6 October 2015 at 18:33, zxq9 <span dir="ltr"><<a href="mailto:zxq9@zxq9.com" target="_blank">zxq9@zxq9.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Wednesday 07 October 2015 10:25:38 zxq9 wrote:<br>
<br>
> or maybe it is that {'EXIT', Pid = self(), kill} *is* specifically untrappable by way of matching on self()?<br>
<br>
</span>That was too much to hope for:<br>
<br>
1> P = spawn(fun Loop() -> receive M -> io:format("Got ~p~n", [M]), Loop() end end).<br>
<0.1889.0><br>
2> P ! {'EXIT', P, kill}.<br>
Got {'EXIT',<0.1889.0>,kill}<br>
{'EXIT',<0.1889.0>,kill}<br>
3> P ! {'EXIT', P, blam}.<br>
Got {'EXIT',<0.1889.0>,blam}<br>
{'EXIT',<0.1889.0>,blam}<br>
4> exit(P, kill).<br>
true<br>
5> P ! {'EXIT', P, blam}.<br>
{'EXIT',<0.1889.0>,blam}<br>
<br>
If it *did* turn out that matching {'EXIT', self(), kill} was untrappable I would just say "ah, that makes sense -- now I can understand the mechanism behind this without thinking about VM details". Instead it appears to be a case of mysterious activity underlying a message form that is semantically overloaded. And that stinks.<br>
<div><div><br>
-Craig<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>
</div></div></div><br></div>