Supervisor shutdown

Gunilla Arendt gunilla@REDACTED
Tue Nov 25 10:11:32 CET 2003


Snip from the gen_server man page:

"If the gen_server is part of a supervision tree and is
 ordered by its supervisor to terminate, this function will
 be called with Reason=shutdown if the following
 conditions apply:
 * the gen_server has been set to trap exit signals, and
 * the shutdown strategy as defined in the
   supervisor's child specification is an integer
   timeout value, not brutal_kill. "

Best regards, Gunilla

HEINRICH VENTER wrote:
> 
> Hello List
> 
> I have a bit of an odd question regarding the shut down of applications.  I have the following sequence
> 
> application -> supervisor -> gen_server
> 
> The gen_server does all the weird and wonderful stuff and needs to be shut down in an orderly fashion. To do that I have a terminate/2 function.
> BUT, If I stop the application with application:stop(myapp). what happens is that the supervisor process gets terminated and thus the gen_server gets terminated too (without calling the terminate/2 function).
> Then I though I'd be clever and use the exported application stop/1 function to call the supervisor:terminate_child/2 function, but this also just kills the child process without calling the termiante/2 function.
> Next I thought I'd kill the gen_server directly in the stop/1 function with my stop/0 function in the gen_server.  But then the supervisor jumped in and restarted the gen_server as soon as it realised that it is dead.
> 
> So how do I stop the application  and ensure that my gen_server terminate code gets executed??
> 
> -]-[einrich
> 
> #####################################################################################
> The information contained in this message and or attachments is intended
> only for the person or entity to which it is addressed and may contain
> confidential and/or privileged material.  Any review, retransmission,
> dissemination or other use of, or taking of any action in reliance upon,
> this information by persons or entities other than the intended recipient
> is prohibited. If you received this in error, please contact the sender and
> delete the material from any system and destroy all copies.
> #####################################################################################

-- 
_____Gunilla Arendt______________________________________________
EAB/UKH/KD Erlang/OTP Product Development
Gunilla.Arendt@REDACTED  +46-8-7275730  ecn 851 5730



More information about the erlang-questions mailing list