According to the Erlang docs, you can use the supervisor:terminate_child function with simple_one_for_one supervisors as long as you pass in the PID of the process instead of the child spec identifier. However, this doesn’t seem to work for me in practice, and instead the function returns back {error, simple_one_for_one}. Here’s what I’m seeing:
(client-1@nick-desktop)9> supervisor:which_children(my_sup).
[{undefined,<0.544.0>,worker,[cf_server]}]
(client-1@nick-desktop)10> P.
<0.544.0>
(client-1@nick-desktop)11> supervisor:terminate_child(my_sup, P).
{error,simple_one_for_one}
Am I doing something wrong, or are the Erlang docs inaccurate? If I can’t stop the process with supervisor:terminate_child, should I just call exit(P, shutdown) instead?
What version of erlang are you running? I think
supervisor:terminate_child/2was only allowed forsimple_one_for_onesupervisors starting in R14B03.