start or re-start?
Martin J. Logan
mlogan@REDACTED
Thu Jul 24 17:04:25 CEST 2003
I encountered a situation where I needed to distinguish between the
start and restart for a given process. The solution that I came up with
was to register with an event_handler with the name of my process in my
init function. The registration function called in init had the side
effect of linking the calling process to the event_manager/handler. When
any such registered process would die the exit signal would be caught
and the event_handler would then indicate via the next call to its
register function that this is not the first time this registration has
been made. The return value of register would also provide the reason
for the last death. It worked reasonably well in lieu of having the
supervisor keep track of exits and restarts. Hope this helps.
Cheers,
Martin
On Thu, 2003-07-24 at 05:29, Luca Manai wrote:
> Hello all,
>
> is there the possibility for a child process to distiguish between
> the two following situations?
>
> [1] the supervisor has started the child for the first time
> (start_child/2 interface)
>
> [2] the supervisor has re-started the child
> (child process crash)
>
> I couldn't come up up with a clean solution...
> (I don't need to distiguish the restart_child/2 situation)
>
> Thanks.
>
> Luca.
More information about the erlang-questions
mailing list