2011-10-21 45 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