Is it (theoretically) possible that the process that's been spawn_monitor()
'ed exits (with the normal exit or on error) without sending 'DOWN'
message to the parent process ? I have a very strange process leakage, it seems like some of the processes do not send 'DOWN'
message. I am using Erlang package that comes with Ubuntu 9.10. Maybe it is a known bug ?
views:
53answers:
2Maybe you demonitored the process at some point?
Reading from the doc for erlang:demonitor/1:
Once erlang:demonitor(MonitorRef) has returned it is guaranteed that no {'DOWN', MonitorRef, _, _, _} message due to the monitor will be placed in the callers message queue in the future. A {'DOWN', MonitorRef, _, _, _} message might have been placed in the callers message queue prior to the call, though. Therefore, in most cases, it is advisable to remove such a 'DOWN' message from the message queue after monitoring has been stopped. erlang:demonitor(MonitorRef, [flush]) can be used instead of erlang:demonitor(MonitorRef) if this cleanup is wanted.
You'll need to show some code. Monitoring is pretty core to the way erlang works.
It's hard to tell what your actual problem is since you're not describing what you're seeing, so I'll have to guess.
You're either not trying to receive the down message or the process isn't exiting.
If you have processes leaking, it sounds like they're not actually exiting.
You very well may be trying to build your own supervisor
module. I'd strongly suggest using OTP's supervisor if you want sane process tree shutdown and/or restart.