[erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug?

Roberto Aloi prof3ta@REDACTED
Tue Feb 24 08:49:55 CET 2015

I just had a quick look at the relevant source code (maint from GitHub).
Indeed, spawn_opt/3 simply calls spawn_opt/5 via erlang:apply/2, so all the
limitations of spawn_opt/5
are also valid for spawn_opt/3. See:


Note that when you use node() as the first argument, the code path is
different and spawn_opt/2 is called instead, so you can use 'monitor' there:


Interesting how you can still use a tuple-fun in spawn_opt/X. I thought
tuple funs were removed in R16.


Regarding execution of funs in remote nodes, here is a nice reading:



On 23 February 2015 at 16:17, Roger Lipscombe <roger@REDACTED>

> I'm attempting to use spawn_opt/3 with a remote node, like this:
>     Fun = fun() -> ok end,
>     {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]).
> It fails with:
>     {badarg,
>       [{erlang,spawn_opt,
>        ['imp_server@REDACTED',erlang,apply,
>         [#Fun<erl_eval.20.80484245>,[]],
>         [link,monitor]],
>        []}
> Now, the documentation at
> http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the
> 'monitor' option is not allowed for spawn_opt/5. It says nothing about
> spawn_opt/3.
> Looking at the error message, it looks like spawn_opt/3 simply calls
> spawn_opt/5. Does this note about 'monitor' being unsupported need to
> be in documentation for both functions?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Roberto Aloi
Website: http://roberto-aloi.com
Twitter: @robertoaloi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150224/21838a4a/attachment.htm>

More information about the erlang-questions mailing list