【问题标题】:Erlang simple_one_for_one supervisor terminate_child isn't workingErlang simple_one_for_one 主管 terminate_child 不工作
【发布时间】:2011-10-22 11:30:27
【问题描述】:

根据 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


    【解决方案1】:

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

    作者:Siri Hansen 日期:2011 年 4 月 12 日星期二 16:47:17 +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.
    

    【讨论】:

    • 谢谢,这就解释了,因为我正在使用 R13B03 :-)
    猜你喜欢
    • 2017-05-02
    • 2016-08-16
    • 2016-06-11
    • 2014-11-27
    • 2014-12-09
    • 2014-11-29
    • 2013-03-21
    • 2011-08-07
    • 2012-11-16
    相关资源
    最近更新 更多