I happen to read about a spawn_opt called monitor: http://www.erlang.org/doc/man/erlang.html#spawn_opt-2
But when I use it, I got this:
1> gen_server:start(some_module, [], [{spawn_opt, [monitor]}]).
** exception error: bad argument
in function proc_lib:check_for_monitor/1 (proc_lib.erl, line 182)
in call from proc_lib:spawn_opt/4 (proc_lib.erl, line 161)
in call from proc_lib:start_link/5 (proc_lib.erl, line 317)
2>
And this is what happens around line 182 in proc_lib.erl from the OTP:
%% OTP-6345
%% monitor spawn_opt option is currently not possible to use
check_for_monitor(SpawnOpts) ->
case lists:member(monitor, SpawnOpts) of
true ->
erlang:error(badarg);
false ->
false
end.
The monitor option is disabled on purpose, but I don't understand why. I searched a bit
on OTP-6345, turns out it's from the release note, where I can't find enough info either: http://www.erlang.org/download/otp_src_R11B-3.readme
We do the spawn-then-monitor steps manually all the time without any problems, but why did the OTP code choose to completely ignore the monitor option ? Are there potential race
conditions or any other traps ?
The fix is related to this email, there seems to be some overlap in the functionality of proc_lib and monitor which screws up this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With