[erlang-questions] Sending a message to a process that no longer exists

Jack Orenstein jao@REDACTED
Wed Dec 10 05:29:30 CET 2008


Thanks for all the responses.

Becoming a system process (suggested by Bernard Duggan) and catching  
'EXIT' works.

Monitoring (suggested by Rapsey) works and provides a bit more  
information than catching 'EXIT', e.g. noconnection. (Or will the  
'EXIT' message do this too?)  erlang:is_process_alive works, but only  
for local processes.  Also, (as pointed out by Robert Virding),  
monitor/2 sends a 'DOWN' message instead of a boolean result that is  
immediately stale, (a problem if the process dies just after the send).

Hynek Vychodil pointed me at gen:do_call/4, which is elaborate but  
looks foolproof.

I tried some timings. For local processes, the extra work done by  
do_call is substantial, lowering message speed by a factor of 3 (on a  
MacBook Pro). For messages to other nodes, the difference is only  
about 10%.

Jack



More information about the erlang-questions mailing list