Skip to content

Instantly share code, notes, and snippets.

@frahugo
Created March 29, 2017 17:37
Show Gist options
  • Save frahugo/2cd3df19ca18b1a4e8b17b5b69919973 to your computer and use it in GitHub Desktop.
Save frahugo/2cd3df19ca18b1a4e8b17b5b69919973 to your computer and use it in GitHub Desktop.
Experiment on process monitoring
defmodule Test do
def run() do
# Span a new process
pid = spawn(fn -> :timer.sleep(100) end)
# Monitor the process
Process.monitor(pid)
# Kill the process
Process.exit(pid, :shutdown)
IO.puts "Process was stopped"
# Flush the messages of the inbox
receive do
message -> IO.inspect(message)
end
end
end
Test.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment