Reputation: 1951
Here is my function :
mydemonitor(Pid) ->
io:format("Demonitor : ~w ~n", [Pid]), %%For debugging and trying to see what's wrong
erlang:demonitor(Pid, [flush]).
And here is what I get :
Demonitor : <0.41.0>
=ERROR REPORT==== 15-Oct-2014::15:32:19 ===
Error in process <0.47.0> with exit value: {badarg,[{erlang,demonitor,[<0.41.0>,[flush]],[]},{node3,mydemonitor,1,[{file,"node3.erl"},{line,213}]},{node3,stabilize,4,[{file,"node3.erl"},{line,147}]},{node3,node,5,[{file,"node3.erl"},{line,46}]}]}
I looked at the man of erlang:demonitor/2
and erlang:demonitor/1
, it seems that I use the right syntax. I tried to use demonitor/1 (so without the flush option) without success.
I really don't see what is wrong, any idea would be greatly appreciated :D
Upvotes: 0
Views: 215
Reputation: 41648
The argument to demonitor/1
and demonitor/2
is not the PID of the process being monitored, but the reference returned by monitor/2
.
Upvotes: 4