Note that there are some explanatory texts on larger screens.

plurals
  1. POErlang exit/2 bug in R15B03
    primarykey
    data
    text
    <p>Short copy from <a href="http://erlang.org/doc/man/erlang.html#exit-2" rel="nofollow">here</a>:</p> <blockquote> <p><code>exit(Pid, Reason) -&gt; true</code></p> <p>Types:</p> <p>Pid = <code>pid()</code> Reason = <code>term()</code></p> <p>Sends an exit signal with exit reason <code>Reason</code> to the process <code>Pid</code>.</p> <p>The following behavior apply if Reason is any term except <code>normal</code> or <code>kill</code>:</p> <p>If <code>Pid</code> is not trapping exits, <code>Pid</code> itself will exit with exit reason <code>Reason</code>. If <code>Pid</code> is trapping exits, the exit signal is transformed into a message <code>{'EXIT', From, Reason}</code> and delivered to the message queue of <code>Pid</code>. <code>From</code> is the pid of the process which sent the exit signal. See also <code>process_flag/2</code>.</p> <p>If <code>Reason</code> is the atom <code>normal</code>, <code>Pid</code> will not exit. If it is trapping exits, the exit signal is transformed into a message <code>{'EXIT', From, normal}</code> and delivered to its message queue.</p> <p>If <code>Reason</code> is the atom <code>kill</code>, that is if <code>exit(Pid, kill)</code> is called, an untrappable exit signal is sent to <code>Pid</code> which will unconditionally exit with exit reason <code>killed</code>.</p> </blockquote> <p>I am playing around with the <code>exit/2</code> function and its behavior when <code>self()</code> is used as a <code>Pid</code> and <code>normal</code> as a <code>Reason</code>.</p> <pre><code>Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.9.3 (abort with ^G) 1&gt; self(). &lt;0.32.0&gt; 2&gt; exit(self(), normal). ** exception exit: normal 3&gt; self(). &lt;0.35.0&gt; </code></pre> <p>Shouldn't it be the case that only a 'normal' exit message is sent to the shell process, so there is no reason to exit?</p> <p>Similarly:</p> <pre><code>4&gt; spawn(fun() -&gt; receive Pid -&gt; Pid ! ok end end). &lt;0.38.0&gt; 5&gt; exit(v(4), normal). true 6&gt; v(4) ! self(). &lt;0.35.0&gt; 7&gt; flush(). Shell got ok ok </code></pre> <p>But:</p> <pre><code>8&gt; spawn(fun() -&gt; exit(self(), normal), receive _ -&gt; ok end end). &lt;0.43.0&gt; 9&gt; is_process_alive(v(8)). false </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload