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

Dave Smith dizzyd@REDACTED
Mon Oct 19 19:44:30 CEST 2009

On Mon, Oct 19, 2009 at 11:39 AM, Pablo Platt <pablo.platt@REDACTED> wrote:
> Sounds like a good solution.
> I'll create a gen_server that will call supervisor:start_child
> then it'll monitor the pid and store it in an ETS so other clients will be
> able to send messags to the child.
> If the child exists or crashes the monitoring gen_server will delete the ETS
> record of this process.
> The complexity is if the monitoring process dies.
> In this case it needs to scan the whole ETS table, re-monitor all live
> process and delete records of all the dead processes.

Well, I suppose it depends on what process owns that ETS table. If
your gen_server owns the ETS table, that table will get deleted at
crash time. In that situation, you could just use
supervisor:which_children to rebuild the table, I suppose.

Of course, it would be easier to just ensure that process never dies. ;)


More information about the erlang-questions mailing list