liveBook · Manning

Exit reason

As explained in Elixir in Action, Third Edition

An exit reason is an Elixir term describing why a process terminated, including the atom :normal for normal termination.

An exit reason is an arbitrary Elixir term describing why a process terminated. A function that finishes normally exits with :normal; exit/1 lets code choose another reason. section 8.2.1 section 8.1.1

Exit reasons determine how concurrent systems react:

  • Linked processes receive the terminating process’s PID and exit reason; non-normal reasons normally propagate termination to linked processes. section 8.2.1
  • Supervisors can restart a crashed child, while :kill unconditionally terminates the target process even when it traps exits. section 8.3.2

Inspecting a linked crash

A linked process that raises emits an exit signal containing its PID and a structured reason, such as a RuntimeError and stacktrace.

How Elixir in Action, Third Edition covers it

How deep it goes
Defines arbitrary terms and :normal, then applies them to links, exit signals, and supervised process restarts.
Examples
Uses :normal, "I'm done", exception terms, and :kill in linked-process and supervisor experiments.
What you can do after
Diagnose process failures by inspecting exit signals and understand when linked or supervised processes terminate or restart.
How it connects
Connects process termination with exit/1, exit signals, links, process isolation, and supervisors.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.