Skip to content

Instantly share code, notes, and snippets.

@alco
Created October 7, 2015 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alco/5e78b968b84177b60030 to your computer and use it in GitHub Desktop.
Save alco/5e78b968b84177b60030 to your computer and use it in GitHub Desktop.
iex(1)> pid = spawn_link(fn -> receive do :foo -> :ok end end)
#PID<0.59.0>
iex(2)> monitor = Process.monitor(pid)
#Reference<0.0.6.73>
# Now make the spawned process go away
iex(4)> send(pid, :foo)
:foo
iex(5)> Process.alive?(pid)
false
# The current process' inbox now contains a DOWN message because it called Process.monitor() before
iex(7)> flush
{:DOWN, #Reference<0.0.6.73>, :process, #PID<0.59.0>, :normal}
:ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment