【发布时间】:2014-12-07 22:23:19
【问题描述】:
在https://github.com/giorgiosironi/erlang-2pc/blob/master/nodes.erl#L95 中,我生成了 3 个进程,它们在算法完成后终止(或者我认为:它们的函数返回)。 我认为 start/0 函数也已终止。
我开始执行这个函数:
erl -noshell -run nodes test_commit -noshell
执行函数后,我得到了预期的输出:
<0.30.0> - As coordinator added cohort: <0.31.0>
<0.31.0> - Will propose: yes
<0.32.0> - Will propose: yes
<0.30.0> - As coordinator added cohort: <0.32.0>
<0.30.0> - As coordinator, 1st phase trying to commit
<0.31.0> - Queried by coordinator
<0.32.0> - Queried by coordinator
<0.30.0> - As coordinator received a yes
<0.30.0> - As coordinator received a yes
<0.30.0> - As coordinator, 2nd phase
<0.31.0> - COMMIT!
<0.32.0> - COMMIT!
<0.30.0> - COMMIT!
但随后外壳会无限期地挂在那里。我用 CTRL+C 退出,然后 (A)bort。
为什么 shell 不能自行终止?在这种挂起状态下,如何从 shell 中检查哪些进程仍然存在?如果正常,如何从我的测试脚本中以编程方式终止它?
【问题讨论】:
-
init:stop()是以干净的方式终止 erlang 的标准方式。它首先停止所有应用程序,然后停止 erlang 系统本身。