defmodule Para do
  def spawn_new(0), do: IO.puts("Spawn done!")
  def spawn_new(n) do
    spawn_link(Para, :new_proc, [])
    spawn_new(n-1)
  end

  def new_proc, do: Process.sleep(10); exit(:kaboom)

  def run do
    Process.flag(:trap_exit, true)
    spawn_new(10)
    listen
  end

  def listen do
    receive do
      {:EXIT, from_pid, reason} ->
        IO.inspect("Exit #{inspect(from_pid)}, reason: #{reason}")
    end 
    listen
  end
end
Para.run

Изменить пасту