3

我从 Erlang 文档中看到 supervisor:start_child 可以返回两个不同的非错误结果:{ok, Child} 和 {ok, Child, Info}。此信息在哪里设置?simple_one_for_one sups 与其他sups 有什么不同吗?我无法找到有关此的示例/文档...

4

1 回答 1

4

Info comes from the function that starts the child process (as given in the child specification in the supervisor). Most of the time, that function will eventually call gen_server:start_link/4 which only returns {ok, Pid} and never {ok, Pid, Info}, so that case only applies when you have a custom function for spawning the process, probably using the functions in the proc_lib module.

Processes that don't use a pre-defined behaviour are called "special processes" and are described in the OTP Design Principles User's Guide.

于 2012-11-19T10:15:25.020 回答