I'm trying to use a supervisor with simple_one_for_one RestartStrategy, and I think I have the latest version of Erlang, but still when I try to execute supervisor:terminate_child it ends up with {error,simple_one_for_one}. According to this answer, it should work if my Erlang is version is greater than R14B03 but I can't seem to find the version starting with 'R' anywhere. When I try erlang:system_info(otp_release) in the Erlang shell, it return with "24", which I think is the latest version released in May 2021, but I could see no other reason for this issue. Here is how my supervisor looks:
-module(a_sup).
-behaviour(supervisor).
%% API
-export([start_link/0, init/1]).
start_link() ->
{ok, supervisor:start_link({local,?MODULE}, ?MODULE, [])}.
init(_Args) ->
RestartStrategy = {simple_one_for_one, 5, 3600},
ChildSpec = {
a_gen_server,
{a_gen_server, start_link, []},
permanent,
brutal_kill,
worker,
[a_gen_server]
},
{ok, {RestartStrategy,[ChildSpec]}}.
You don't show your code for terminating a child, but are you indicating the child to terminate using an identifier instead of a pid? The terminate_child/2 documentation says:
Regarding the version issue: 24.2 is the current Erlang/OTP version at the time of this writing. Version numbers used to start with 'R' but that ended at Erlang/OTP 17.0.