<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;" class="">I think the logic is in the different explicit intent, which is present when exit/2ing someothing with ‘kill’, but absent when crashing with ‘kill’. Besides, crashing with ‘kill’ behaving “consistently” would mean broadcasting a brutal kill, which is rarely, if ever, desirable.<br class=""><div><blockquote type="cite" class=""><div class="">5 мая 2017 г., в 15:32, Robert Virding <<a href="mailto:rvirding@gmail.com" class="">rvirding@gmail.com</a>> написал(а):</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class="">Yes, and no. When a process dies with a reason then that reason is sent in a signal to all the processes in the link set. So if the process dies with the reason 'foo' then a 'foo' exit signal will be sent, and if I do exit/2 to send a 'foo' exit signal then a 'foo' exit signal will be sent. In both cases, if the receiving process is not trapping it will die with the reason 'foo' [*] and if the receiving process is trapping then the exit signal will be converted to a message with reason 'foo'. In both cases it IS a 'foo' exit signal.<br class=""><br class=""></div>However, if the exit reason is 'kill' then the 'kill' exit signal sent from the process will be trapped while if it is sent with exit/2 it is not trappable. THIS IS THE ONLY EXIT SIGNAL WHICH BEHAVES DIFFERENTLY! [**]<br class=""><br class=""></div><div class="">Again where's the logic in that? Why the inconsistency? We tried hard back in the old days to be consistent.<br class=""></div><div class=""><br class=""></div><div class="">Robert<br class=""><br class=""></div><div class="">* As 'foo' is not the value 'normal' it will kill the process.<br class=""></div>**Sorry of raising my voice.<br class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On 5 May 2017 at 14:08, Alex S. <span dir="ltr" class=""><<a href="mailto:alex0player@gmail.com" target="_blank" class="">alex0player@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There is exit/1 and exit/2 which are very, very different things. exit/1 is NOT an exit signal.<br class="">
There is no “kill and kill”, there is exit signal kill, which is special, and exit reason kill, which is not special.<br class="">
> 5 мая 2017 г., в 15:05, Robert Virding <<a href="mailto:rvirding@gmail.com" class="">rvirding@gmail.com</a>> написал(а):<br class="">
<div class="HOEnZb"><div class="h5">><br class="">
> There is more. So:<br class="">
><br class="">
> 1> process_flag(trap_exit, true).<br class="">
> false<br class="">
> 2> Pid = spawn_link(fun() -> process_flag(trap_exit,true), timer:sleep(infinity) end).<br class="">
> <0.60.0><br class="">
><br class="">
> We trap exits and spawn_link which also traps exits and just hangs there waiting.<br class="">
><br class="">
> 3> spawn(fun() -> link(Pid), exit(kill) end).<br class="">
> <0.62.0><br class="">
> 4> process_info(Pid, messages).<br class="">
> {messages,[{'EXIT',<0.62.0>,<wbr class="">kill}]}<br class="">
><br class="">
> Now we spawn a new process which links to our hanger and exits with the reason 'kill'. We can then check our hanger and see that it received a 'kill' signal which it converted to a message because it was trapping. Finally:<br class="">
><br class="">
> 5> spawn(fun() -> exit(Pid, kill) end).<br class="">
> <0.65.0><br class="">
> 6> flush().<br class="">
> Shell got {'EXIT',<0.60.0>,killed}<br class="">
> ok<br class="">
><br class="">
> we spawn another process which uses exit/2 to send a 'kill' signal to our hanger and in this case it cannot trap the signal and dies with the reason 'killed'. So there is 'kill' and 'kill' depending on how I send it.<br class="">
><br class="">
> Where's the logic in that?<br class="">
><br class="">
> Robert<br class="">
><br class="">
> P.S. Yes, I know that getting a 'killed' from a process which has been killed with a 'kill' signal is the correct.<br class="">
><br class="">
</div></div><div class="HOEnZb"><div class="h5">> ______________________________<wbr class="">_________________<br class="">
> erlang-questions mailing list<br class="">
> <a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank" class="">http://erlang.org/mailman/<wbr class="">listinfo/erlang-questions</a><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>