I have a standalone application in which I have to prompt the user with an confirm dialog box to save the changes made by him when he tries to shutdown the system by start-->shutdown.
I came to know that by using signalhandlers we can do it.
Can some one help me how to use signal handlers
Update May 2012 (2 and half years later)
Trejkaz comments:
The chapter “Integrating Signal and Exception Handling” of the “Troubleshooting Guide for HotSpot VM” mentions the signals “
SIGTERM,SIGINT,SIGHUP” only for Solaris OS and Linux.Only Exception Handling on Windows are mentioned.
Original answer (Sept 2009)
a ShutdownHook should be able to handle that case
(with caveats)
See also:
as an illustration of simple signal handling: