Search⌘ K
AI Features

When Processes Die

Explore how Elixir manages processes that terminate unexpectedly. Learn to link processes, trap exit signals for custom handling, and monitor process lifecycles to build fault-tolerant concurrent applications.

When a process dies

Who gets told when a process dies? By default, no one. Obviously, the VM knows and can report it to the console, but our code will be oblivious unless we explicitly tell Elixir we want to get involved. Here’s the default case: we spawn a function that uses the Erlang timer library to sleep for 500 ms. It then exits with a status of :boom. The code that spawns it sits in a receive. If it receives a message, it reports that fact. Otherwise, after one second, it lets us know that nothing happened.

Run the elixir -r link1.exs ...