开发者

spawn_monitor() and 'DOWN' messages

开发者 https://www.devze.com 2022-12-24 13:40 出处:网络
Is it (theoretically) possible that the process that\'s been spawn_monitor()\'ed exits (with the normal exit o开发者_开发知识库r on error) without sending \'DOWN\' message to the parent process ? I ha

Is it (theoretically) possible that the process that's been spawn_monitor()'ed exits (with the normal exit o开发者_开发知识库r 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 ?


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.


Maybe 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号