Created
March 29, 2017 17:37
-
-
Save frahugo/2cd3df19ca18b1a4e8b17b5b69919973 to your computer and use it in GitHub Desktop.
Experiment on process monitoring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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