Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Info in return value {ok, Child, Info} for supervisor:start_child come from?

I see from the Erlang docs that supervisor:start_child can return two different non-error results: {ok, Child} and {ok, Child, Info}. Where does this Info get set? Is it different for simple_one_for_one sups as opposed to others? I haven't been able to find an example / documentation on this...

like image 262
Tom H. Avatar asked Nov 15 '25 19:11

Tom H.


1 Answers

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.

like image 129
legoscia Avatar answered Nov 17 '25 10:11

legoscia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!