Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the reason can be found from the source code 'stdlib-1.18.2/src/shell.erl'. </p> <pre><code>get_command(Prompt, Eval, Bs, RT, Ds) -&gt; Parse = fun() -&gt; exit(io:parse_erl_exprs(Prompt)) end, Pid = spawn_link(Parse), get_command1(Pid, Eval, Bs, RT, Ds). get_command1(Pid, Eval, Bs, RT, Ds) -&gt; receive {'EXIT', Pid, Res} -&gt; {Res, Eval}; {'EXIT', Eval, {Reason,Stacktrace}} -&gt; report_exception(error, {Reason,Stacktrace}, RT), get_command1(Pid, start_eval(Bs, RT, Ds), Bs, RT, Ds); {'EXIT', Eval, Reason} -&gt; report_exception(error, {Reason,[]}, RT), get_command1(Pid, start_eval(Bs, RT, Ds), Bs, RT, Ds) end. report_exception(Class, Reason, RT) -&gt; report_exception(Class, serious, Reason, RT). report_exception(Class, Severity, {Reason,Stacktrace}, RT) -&gt; Tag = severity_tag(Severity), I = iolist_size(Tag) + 1, PF = fun(Term, I1) -&gt; pp(Term, I1, RT) end, SF = fun(M, _F, _A) -&gt; (M =:= erl_eval) or (M =:= ?MODULE) end, io:requests([{put_chars, Tag}, {put_chars, lib:format_exception(I, Class, Reason, Stacktrace, SF, PF)}, nl]). start_eval(Bs, RT, Ds) -&gt; Self = self(), Eval = spawn_link(fun() -&gt; evaluator(Self, Bs, RT, Ds) end), %%&lt;========start a new shell pid put(evaluator, Eval), Eval. severity_tag(fatal) -&gt; &lt;&lt;"*** "&gt;&gt;; severity_tag(serious) -&gt; &lt;&lt;"** "&gt;&gt;; severity_tag(benign) -&gt; &lt;&lt;"* "&gt;&gt;. </code></pre> <p>For your first case (sending message to self()), the signal meets the 2nd situation of <code>get_command1/5</code>, it will give error message firstly, and spawn a new shell pid. Please pay attention to <code>start_eval</code> function.</p> <p>For your second case (sending message to a spawn <code>pid</code>), Going back to your first part of post about the <code>exit</code> function, it is logical. Your spawned <code>pid</code> doesn't trap the exit message, and ignore the <code>(normal) exit</code> message. so the <code>shell</code> will receive exit message only when your spawn <code>pid</code>'s actual exit. It will go to the 1st condition of <code>get_command1/5</code>. Because <code>start_evel</code> is not been called, <code>shell pid</code> will keep the same.</p> <p>For your third case, I don't know why. I also think <code>is_process_alive(v(8))</code> should return true.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      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