<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body 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 class="moz-txt-link-freetext" href="http://www.erlang.org/documentation/doc-4.8.2/lib/stdlib-1.6.1/doc/html/supervisor.html">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
        class="code">transient</span></tt><tt> child process will be
      restarted only if it terminates abnormally, i.e. with another exit
      reason than </tt><tt><span class="code">normal</span></tt><tt>, </tt><tt><span
        class="code">shutdown</span></tt><tt> or </tt><tt><span
        class="code">{shutdown,Term}"
        (<a class="moz-txt-link-freetext" href="http://www.erlang.org/doc/man/supervisor.html">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 class="code"><br>
        Thanks,<br>
        Michael<br>
      </span></tt>
  </body>
</html>