<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <span class="code">shell:catch_exception/1 is</span> another trick
    for shell.<br>
    You don't need to unlink the process as the shell isn't get killed
    if exceptions happen.<br>
    <br>
    1> self().<br>
    <0.34.0><br>
    2> 1/0.<br>
    ** exception error: an error occurred when evaluating an arithmetic
    expression<br>
         in operator  '/'/2<br>
            called as 1 / 0<br>
    3> self().<br>
    <0.37.0><br>
    4> catch_exception(true).<br>
    false<br>
    5> 1/0.<br>
    * exception error: an error occurred when evaluating an arithmetic
    expression<br>
        in operator  '/'/2<br>
           called as 1 / 0<br>
    6> self().<br>
    <0.37.0><br>
    7> <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 09/27/2015 01:28 PM, Vimal Kumar
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAMO=R+Qzh_wz1QKR+8OGwpdatuMROkGCbf-GUZzjAbgxbq8rqQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Jesper,
        <div><br>
        </div>
        <div>I now implemented supervision trees along with the
          application controller, and things now work as it should be.</div>
        <div><br>
        </div>
        <div>
          <div>1> application:start(mybank).</div>
          <div>ok</div>
          <div><br>
          </div>
          <div>
            <div>2> whereis(bank_server).</div>
            <div><0.38.0></div>
          </div>
          <div><br>
          </div>
          <div>3> bank_server:new_user(user1, "d3fault").</div>
          <div>{ok}</div>
          <div><br>
          </div>
          <div>4> {_, UniqueId} = bank_server:login(user1,
            "d3fault").</div>
          <div>{ok,"OsNTJVIQgyb9ERHg3q9SLg=="}</div>
          <div><br>
          </div>
          <div>5> bank_server:new_user(user2, "d3fault").          
              </div>
          <div>{ok}</div>
          <div><br>
          </div>
          <div>6> {_, UniqueId} = bank_server:login(user2,
            "d3fault").</div>
          <div>** exception error: no match of right hand side value
            {ok, "w7MJ1HQrHIDbVlNOh5bSpg=="} </div>
          <div><br>
          </div>
          <div>7> whereis(bank_server).</div>
          <div><0.38.0></div>
        </div>
        <div><br>
        </div>
        <div>Unlinking the process is a great tip for testing from
          shell, didn't cross my mind.</div>
        <div><br>
        </div>
        <div>Thanks!</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Sun, Sep 27, 2015 at 3:24 PM, Jesper
          Louis Andersen <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:jesper.louis.andersen@gmail.com"
              target="_blank">jesper.louis.andersen@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div class="gmail_extra"><span class=""><br>
                  <div class="gmail_quote">On Sun, Sep 27, 2015 at 10:52
                    AM, Vimal Kumar <span dir="ltr"><<a
                        moz-do-not-send="true"
                        href="mailto:vimal7370@gmail.com"
                        target="_blank">vimal7370@gmail.com</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">Going
                      to add supervisors into this system and learn more
                      about it.</blockquote>
                  </div>
                  <br>
                </span>It doesn't happen in real systems, because the
                supervision trees are linked to the application
                controller, and not the shell. If you simply add a
                supervision tree, and link that tree to the shell, you
                are usually not free of the problem.</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">When developing however, you can
                unlink the pid:</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">{ok, P} = foo:start_link().</div>
              <div class="gmail_extra">unlink(P).</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">which will have P not die if the
                shell does.</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">The other resources to look out
                for are ETS tables, and port()'s, that is network
                sockets and files. If their controlling process, i.e.
                the shell, goes away, then that resource is
                cleaned/reaped/closed again.</div>
              <span class="HOEnZb"><font color="#888888">
                  <div class="gmail_extra"><br clear="all">
                    <div><br>
                    </div>
                    -- <br>
                    <div>J.</div>
                  </div>
                </font></span></div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>