title: Is there a way to modify when the kill message is sent to any process all others has to die?
body: <p>Thanks for taking a look at my question.</p>
  <p>I wrote a code for the question ring problem from the o'reilly francesco cesarini and simpson thompson, Exercise 4-2: The Process Ring.</p>
  <p>Now here's my question,How can I modify the code so that when message kill is sent to any process, all the other process should die automatically without the message getting propagated through the ring.</p>
  <p>Even If you can't solve it, just thanks for at least looking at it. This is for my own curiosity on what would happen if this is how it goes and thanks again I'll share the code and the original question so that you guys can understand.</p>
  <p><strong>Original question</strong> : Write a program that will create N processes connected in a ring, as shown in Figure 4-17. Once started, these processes will send M number of messages around thering and then terminate gracefully when they receive a quit message. You can start the
  ring with the call ring:start(M, N, Message).</p>
  <p><a href="https://i.stack.imgur.com/S4tfm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S4tfm.png" alt="This is the reference" /></a></p>
  <p><strong>The Code</strong> :</p>
  <pre><code>-module(r).
  -export([start/3,processes/1]).
  
  start(M, N, Message) -&gt;
    io:format(&quot;Central Process pid: ~w\n&quot;, [self()]),
    { ok, NextPid } = spawner(N),
    ok = sender(Message, M, NextPid),
    ok = sender(stop, 1, NextPid),
    ok.
  
  spawner(N) -&gt;
    spawner(N, self()).
        
  spawner(1, Nring) -&gt;
    { ok, Nring };
              
  spawner(N, Nring) -&gt;
    Pid = spawn(r, processes, [Nring]),
    spawner(N - 1, Pid).
    
  processes(Nring) -&gt;
    loop(Nring).
  
  loop(Nring) -&gt;
    receive
      { stop, From } -&gt;
        io:format(&quot;~w received stop from ~w\n&quot;, [self(), From]),
        Nring ! { stop, self() },
        ok;
      { Msg, From } -&gt;
        io:format(&quot;~w received ~w from ~w\n&quot;, [self(), Msg, From]),
        Nring ! { Msg, self() },
        loop(Nring)
    end.
    
  sender(Msg, Times, NextPid) -&gt;
    NextPid ! { Msg, self() },
    ok = receiver(Msg),
    case Times &gt; 1 of
      true -&gt;
        sender(Msg, Times - 1, NextPid);
      false -&gt;
        ok
    end.
    
  receiver(Msg) -&gt;
    receive
        { Msg, From } -&gt;
        io:format(&quot;~w received ~w from ~w\n&quot;, [self(), Msg, From]),
        ok
    end.
  </code></pre>
  <p>Pardon me If there's any spelling mistake and I would really appreciate it. Thank you so much.</p>