Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A comment to your question on @PetrKozorezov 's answer. The shell is not behaving specially in any way. The shell worker process is just a normal process so if any process to which it is linked crashes then it will also crash. Another worker process will then be started. This is the normal <em>Erlang way</em>.</p> <p>Your <code>start/0</code> <strong>function</strong> just returns and does <strong>NOT</strong> terminate its process, it just outputs the "dying of boredom" message. That is why the loop keeps on going, it doesn't get an <code>exit</code> signal because no process has died.</p> <p>When you change the <code>start/0</code> function to end with <code>exit(normal)</code> <strong>then</strong> you do terminate the shell process so an <code>exit</code> signal is sent to the loop process which then gets the <code>{'EXIT',...,...}</code> message and dies.</p> <p>When @PetrKozorezov spawned your original <code>start/0</code> function in a separate process which then died after executing <code>start/0</code> it sent an exit <code>normal</code> signal to the loop process which caused it to die.</p> <p>This is perfectly normal Erlang behaviour and style. You would normally <strong>not</strong> end a <em>start</em> function with an <code>exit</code> but leave it up to the caller to decide when to die.</p> <p>One more small point: as the start function does a <code>spawn_link</code> you would normally call it <code>start_link</code> instead. A <code>start</code> function is assumed to just <code>spawn</code> a process. This is, of course, just a convention, but a common one, so you have not made an error.</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