Created
June 19, 2012 14:03
-
-
Save elbrujohalcon/2954398 to your computer and use it in GitHub Desktop.
Linked processes in Erlang… when do they die?
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
20> P1 = spawn(fun() -> receive stop -> io:format("P1 ended~n") end end). | |
<0.61.0> | |
21> P2 = spawn(fun() -> link(P1), receive stop -> io:format("P2 ended~n") end end). | |
<0.63.0> | |
22> {erlang:is_process_alive(P1), erlang:is_process_alive(P2)}. | |
{true,true} | |
23> P1 ! stop. | |
P1 ended | |
stop | |
24> {erlang:is_process_alive(P1), erlang:is_process_alive(P2)}. | |
{false,true} | |
25> P2 ! stop. | |
P2 ended | |
stop | |
26> f(). | |
ok | |
27> P1 = spawn(fun() -> receive stop -> io:format("P1 ended~n") end end). | |
<0.70.0> | |
28> P2 = spawn(fun() -> link(P1), receive stop -> io:format("P2 ended~n") end end). | |
<0.72.0> | |
29> {erlang:is_process_alive(P1), erlang:is_process_alive(P2)}. | |
{true,true} | |
30> exit(P1, kill). | |
true | |
31> {erlang:is_process_alive(P1), erlang:is_process_alive(P2)}. | |
{false,false} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment