Supervisor shutdown

HEINRICH VENTER HEINRICH.VENTER@REDACTED
Tue Nov 25 09:44:14 CET 2003


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.
#####################################################################################



More information about the erlang-questions mailing list