Note that there are some explanatory texts on larger screens.

plurals
  1. POErlang process dies after disconnect
    text
    copied!<p>I got the following setup:</p> <ul> <li>2 Servers with fqdn usa.local and gca.local</li> <li>1 erlang node on each of them named alice@usa.local and bob@gca.local</li> </ul> <p>When I start Alice (<code>alice:start/0</code>) on alice@usa.local it spawns linked Bob (<code>bob:start/1</code>) on gca.local. Both processing are trapping exits.</p> <p>When Alice dies of something, Bob gets notified and keeps on running. When Bob dies of something, Alice gets notified and keeps on running.</p> <p>When I cut the network connection, Alice gets notified that Bob has died of <code>noconnection</code> and process bob dies on bob@gca.local.</p> <p>I do not want this to happen. I want Bob to keep on running although it looses connection to Alice.</p> <p><strong>My questions are:</strong></p> <ul> <li>Has this something to do that I initially spawn Bob from the Alice node?</li> <li>How can I make Bob to survive a connection loss?</li> </ul> <hr> <p>Here goes the code:</p> <pre><code>-module (alice). -compile (export_all). start () -&gt; register (alice, spawn (fun init/0) ). stop () -&gt; whereis (alice) ! stop. init () -&gt; process_flag (trap_exit, true), Bob = spawn_link ('bob@gca.local', bob, start, [self () ] ), loop (Bob). loop (Bob) -&gt; receive stop -&gt; ok; {'EXIT', Bob, Reason} -&gt; io:format ("Bob died of ~p.~n", [Reason] ), loop (Bob); Msg -&gt; io:format ("Alice received ~p.~n", [Msg] ), loop (Bob) end. </code></pre> <hr> <pre><code>-module (bob). -compile (export_all). start (Alice) -&gt; process_flag (trap_exit, true), register (bob, self () ), loop (Alice). loop (Alice) -&gt; receive stop -&gt; ok; {'EXIT', Alice, Reason} -&gt; io:format ("Alice died of ~p.~n", [Reason] ), loop (Alice); Msg -&gt; io:format ("Bob received ~p.~n", [Msg] ), loop (Alice) after 5000 -&gt; Alice ! "Hi, this Bob", loop (Alice) end. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload