Skip to content

Instantly share code, notes, and snippets.

@cybrox
Created April 30, 2019 10:48
Show Gist options
  • Save cybrox/1be651edce012d3d457e6da0e24544f2 to your computer and use it in GitHub Desktop.
Save cybrox/1be651edce012d3d457e6da0e24544f2 to your computer and use it in GitHub Desktop.
ex-mag3.ex
defmodule Pragmatic do
def supervisor(worker) do
spawn_link(fn ->
Process.flag(:trap_exit, true)
worker_pid = spawn_link(worker)
receive do
{:EXIT, ^worker_pid, _} ->
supervisor(worker)
end
end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment