Erlang simple_one_for_one 主管终止子不工作

标签 erlang

根据 Erlang 文档,只要您传入进程的 PID 而不是子规范标识符,就可以将supervisor:terminate_child 函数与 simple_one_for_one 主管一起使用。然而,这在实践中似乎对我不起作用,相反该函数返回 {error, simple_one_for_one}。这是我所看到的:

(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}

我做错了什么,还是 Erlang 文档不准确?如果我无法使用 Supervisor:terminate_child 停止进程,我应该调用 exit(P, shutdown) 吗?

最佳答案

您运行的 erlang 版本是什么?我认为 supervisor:terminate_child/2 只允许用于从 R14B03 开始​​的 simple_one_for_one 主管。

Author: Siri Hansen Date: Tue Apr 12 16:47:17 2011 +0200

Allow supervisor:terminate_child(SupRef,Pid) for simple_one_for_one

supervisor:terminate_child/2 was not allowed if the supervisor used
restart strategy simple_one_for_one. This is now changed so that
children of this type of supervisors can be terminated by specifying
the child's Pid.

关于Erlang simple_one_for_one 主管终止子不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7854270/

相关文章:

regex - 如何在 Elixir 中操作正则表达式替换字符串

linux - Rebar3 从主机操作系统释放 ERTS 文件?

适用于 Debian 和 Ubuntu 的 erlang 零依赖安装程序

erlang - 为什么erlang io是:format output being lost and what do I need to do to restore it?

sockets - 失去连接后尽快断开流式 HTTP 连接

c++ - 使用 Erlang 消息传递在模拟中表示并发电梯

process - Erlang 完成或杀死进程

erlang - Threaded Erlang C-Node(cnode) 互操作性如何?

erlang - Erlang 术语存储 (ETS) 存储在哪里?

Erlang 内部函数的递归