<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 09/09/2015 01:31 AM, Siri Hansen
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAGqERUE0MK11fsXqV0Dwz0godKzjxVXykvMiuk++sc=aDJwGcg@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Michael,
        <div><br>
        </div>
        <div>I think that the child spec is kept in the supervisor so
          that one is allowed to do supervisor:restart_child/2. This has
          been the behavior at least as far back as the git repository
          goes. And given that the text was changed as far back as
          OTP-R8B,  I don't think that the old documentation is a reason
          for changing this behavior. <br>
        </div>
      </div>
    </blockquote>
    That is fine, but documentation could be added to make sure this
    behavior is clear, since it is contrary to the definition of
    "transient":<br>
    1a passing especially quickly into and out of existence<br>
    (<a class="moz-txt-link-freetext" href="http://www.merriam-webster.com/dictionary/transient">http://www.merriam-webster.com/dictionary/transient</a>)<br>
    <br>
    I assume temporary has a similar problem.<br>
    <br>
    <blockquote
cite="mid:CAGqERUE0MK11fsXqV0Dwz0godKzjxVXykvMiuk++sc=aDJwGcg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Regards </div>
        <div>/siri</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2015-07-10 3:53 GMT+02:00 Michael Truog
          <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:mjtruog@gmail.com" target="_blank">mjtruog@gmail.com</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> <tt>Hi,</tt><tt><br>
              </tt><tt><br>
              </tt><tt>I have noticed that when the supervisor has a
                child process with the childspec restart set to
                transient, and the process </tt><tt>terminates in a way
                that is not abnormal, the childspec remains within the
                supervisor.  This appears to be an error based on old
                documentation: "</tt><tt>When a </tt><code>temporary</code><tt>
                child dies for any reason or a </tt><code>transient</code><tt>
                child dies normally, the child is removed from the
                supervisor." (<a moz-do-not-send="true"
href="http://www.erlang.org/documentation/doc-4.8.2/lib/stdlib-1.6.1/doc/html/supervisor.html"
                  target="_blank">http://www.erlang.org/documentation/doc-4.8.2/lib/stdlib-1.6.1/doc/html/supervisor.html</a>). 

                The new documentation states: "</tt><tt>a </tt><tt><span>transient</span></tt><tt>
                child process will be restarted only if it terminates
                abnormally, i.e. with another exit reason than </tt><tt><span>normal</span></tt><tt>,
              </tt><tt><span>shutdown</span></tt><tt> or </tt><tt><span>{shutdown,Term}"

                  (<a moz-do-not-send="true"
                    href="http://www.erlang.org/doc/man/supervisor.html"
                    target="_blank">http://www.erlang.org/doc/man/supervisor.html</a>),
                  and this statement is true with the current supervisor
                  code.<br>
                  <br>
                  Is it an error that transient processes that terminate
                  in a way that is not abnormal do not get removed from
                  the supervisor?  I think it is, but I am not sure if
                  this was accepted legacy behavior that the
                  documentation didn't want to contradict.  I have an
                  example below with output:<br>
                  <br>
                  -module(test).<br>
                  -behaviour(supervisor).<br>
                  -export([start_link/0, test_child/0, test/0, init/1]).<br>
                  start_link() -><br>
                      supervisor:start_link({local, ?MODULE}, ?MODULE,
                  []).<br>
                  test_child() -><br>
                      {ok, erlang:spawn_link(fun() ->
                  erlang:exit(normal) end)}.<br>
                  test() -><br>
                      ChildSpec = {test, {test, test_child, []},
                  transient, 2000, worker, []},<br>
                      supervisor:start_child(?MODULE, ChildSpec).<br>
                  init([]) -><br>
                      {ok, {{one_for_one, 5, 300}, []}}.<br>
                  <br>
                  <br>
                  Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:2:2]
                  [ds:2:2:10] [async-threads:10] [kernel-poll:false]<br>
                  <br>
                  Eshell V7.0  (abort with ^G)<br>
                  1> {ok, Sup} = test:start_link().<br>
                  {ok,<0.35.0>}<br>
                  2> erlang:unlink(Sup).<br>
                  true<br>
                  3> {ok, P} = test:test().<br>
                  {ok,<0.38.0>}<br>
                  4> erlang:is_process_alive(P).<br>
                  false<br>
                  5> supervisor:which_children(test).<br>
                  [{test,undefined,worker,[]}]<br>
                  6> test:test().<br>
                  {error,already_present}<br>
                  <br>
                  Isn't keeping the entry in the supervisor, after a
                  termination that is not abnormal, an error?<br>
                </span></tt><tt><span><br>
                  Thanks,<br>
                  Michael<br>
                </span></tt> </div>
            <br>
            _______________________________________________<br>
            erlang-bugs mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
            <a moz-do-not-send="true"
              href="http://erlang.org/mailman/listinfo/erlang-bugs"
              rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>