2011-10-21 105 views
2

根据Erlang文档,只要您传递进程的PID而不是子规范标识符,就可以使用supervisor:terminate_child函数和simple_one_for_one supervisors。但是,在实践中,这似乎不适用于我,而是函数返回{error,simple_one_for_one}。这里是我所看到的:Erlang simple_one_for_one supervisor terminate_child不工作

([email protected])9> supervisor:which_children(my_sup). 
[{undefined,<0.544.0>,worker,[cf_server]}] 
([email protected])10> P. 
<0.544.0> 
([email protected])11> supervisor:terminate_child(my_sup, P). 
{error,simple_one_for_one} 

我做错了什么,或者是Erlang文档不准确?如果我不能用supervisor:terminate_child来停止进程,我应该改用exit(P,shutdown)吗?

回答

4

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

作者:Siri的汉森日期:星期二4月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. 
+0

谢谢,这解释了它,因为我使用R13B03 :-) – Nick