[erlang-questions] excute code in the supervisor when a child crashes?

Roberto Aloi roberto.aloi@REDACTED
Mon Oct 19 19:23:02 CEST 2009


Hi Pablo,

what you actually need is an event handler. More information here:
http://www1.erlang.org/doc/design_principles/events.html
http://www.erlang.org/doc/man/gen_event.html

One approach could be to append a handler process to your supervisor,  
managing the ets table whenever one of the children crash.
Regards,

Roberto Aloi
roberto.aloi@REDACTED
http://www.erlang-consulting.com
---




On Oct 19, 2009, at 5:12 PM, Pablo Platt wrote:

> Hi,
>
> I have a supervisor with simple_one_for_one.
> When I start children with supervisor:start_child I save the child  
> pid in an ETS table
> so I'll be able to exchange messages between all the child processes.
>
> When a child crashes I need to delete his pid from the ETS table or  
> it'll grow constantly and eat all my memory.
> Is it possible to execute code when a child crashes or terminates?
>
> Thanks
>
>



More information about the erlang-questions mailing list