Otp应用程序:stop(..)杀死所有生成的进程,而不仅仅是spawn_linked进程?

bar*_*nen 2 erlang

我在https://github.com/bvdeenen/otp_super_nukes_all上设置了一个简单的测试用例,它显示了一个otp应用程序:stop()实际上会杀死所有衍生进程的子进程,甚至是那些没有链接的进程.

测试用例包括一个gen_server(注册为par)产生一个普通的erlang进程(注册为par_worker)和一个gen_server(注册为reg_child),它还产生一个普通的erlang进程(注册为child_worker).调用应用程序:stop(test_app)在'par'gen_server上正常终止,但在所有其他人上退出(kill)!

这是名义上的行为吗?如果是这样,它在哪里记录,我可以禁用它吗?我希望我从gen_server(不是链接)生成的进程在应用程序终止时保持活动状态.

谢谢

Bart van Deenen

mar*_*log 5

应用手册说(用于停止/ 1功能):

Last, the application master itself terminates. Note that all processes with the
application master as group leader, i.e. processes spawned from a process belonging
to the application, thus are terminated as well.
Run Code Online (Sandbox Code Playgroud)

所以我想你不能修改这个行为.

编辑:您可以使用group_leader(GroupLeader,Pid) - > true更改已启动进程的group_leader(请参阅:http://www.erlang.org/doc/man/erlang.html#group_leader-2 ).更改group_leader可能允许您避免在应用程序结束时终止您的进程.