[erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. How to monitor a remote process?

Roger Lipscombe roger@REDACTED
Mon Feb 23 16:21:12 CET 2015


Note that, despite the preamble, this is a different question to the
other one I just posted. Honest.

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.

How do I monitor a process that I spawn on a remote node?

If I use spawn_link followed by monitor, there's a race where the
remote process could have exited already, and I get {'DOWN', Ref,
process, Pid, noproc}, which is disconcerting.

I want to know when it's finished. Preferably without it needing to
explicitly send a message back to me.



More information about the erlang-questions mailing list