Hi!<div><br></div><div>The strange behaviors that you have discovered are really the expected behaviors. However, I do agree that the documentation is a bit incomplete on these issues.<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In f_sup1, after killing the child process, I try to delete it by calling supervisor:delete_child, it returns {error,running}.<br></blockquote><div><br></div><div>This is a timing issue - since exit/1 is asynchronous, delete_child/2 will be called before the process is actually terminated.</div>
<div>However, if you add an appropriate timer:sleep(...) between the two calls, you will get {error,not_found} instead. This is because a temporary child is automatically deleted when it terminates, since such processes can never be restarted anyway. </div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In f_sup2, if a child processes exits with reason normal, a temporary child process cannot be restarted, but transient process can. So f_sup2 returns{{error,not_found},{ok,<0.364.0>}}. This seems inconsistent because a transient process that exits with reason normal is not supposed to be restarted.<br>
</blockquote><div><br></div><div>It is correct that a transient process which terminates with reason normal is not automatically restarted by the supervisor. However, it is still possible to explicitly restart it by calling supervisor:restart_child as long as you have not deleted the child spec by calling supervisor:delete_child. Only temporary processes can not be restarted this way. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In f_sup3, if a transient child process exits with the reason shutdown, it won't be restarted. It seems strange, since, a transient child process should be restarted unless it is terminated with the reason normal.<br>
</blockquote><div><br></div><div>The exit reason 'shutdown' has a special meaning in OTP - it is the exit reason used by a supervisor when terminating its children. Obviously, the child shall not be automatically restarted after such termination.</div>
<div> </div><div>I will have a look at the documentation and try to make it more clear.</div><div><br></div><div>Regards</div><div>/siri@otp</div></div></div>