Hey gents,
I have a master process starting sub-processes of two kinds and then monitoring their completion. The master process is GenServer and I figured that in order to differentiate between subprocess1 and subprocess2 I need to call "exit(:subprocess1)" and "exit(:subprocess2)" in them, and then catch it with handle_info callback on the master process side, like this:
defmodule Master do
use GenServer
...
def handle_info({ :DOWN, _ref, :process, _pid, :subprocess1 }, state), do: { ... }
def handle_info({ :DOWN, _ref, :process, _pid, :subprocess2 }, state), do: { ... }
end
The problem I'm facing is that when I do "exit(:normal)" in the subprocess, the callback arrives as:
handle_info({ :DOWN, <ref>, :process, <pid>, :normal }, <state>)
.. but if I send "exit(:subprocess1)", it calls:
handle_info({ :DOWN, <ref>, :process, <pid>, :subprocess1 }, :normal)
NOTICE: <state> is now not sent, but there's ":normal" instead.
Can anyone explain what goes on?
Can anyone suggest a better approach? Just to reiterate, I need to follow the completion of two kinds of processes (and update counters in the state.)
Thanks,
- Aleks