Hi,
I created a Java Gui Program (using SWT) and Java's Shutdown Hook doesn't work in Ubuntu.
I am using Sun Jre 1.6 installed via the Synaptic Package Manager.
When my application starts, I am creating a lock file and when my application successfully shutsdown, I am deleting the lock file. The delete lock file code is in the shutdown hook thread.
If I leave my application running while I log off or restart Ubuntu, I still see the lock file, meaning, the shutdown hook never got fired.
If I END PROCESS the java process while my application is running (via System Monitor's Processes tab) then the shutdown hook works.
However, if I KILL PROCESS the java process, then the shutdown hook doesn't work.
So, that makes me believe that when Ubuntu shutsdown, restarts or when the user logs off, Ubuntu sends Kill Process (SIGKILL) to the Java process and may be to all processes instead of sending SIGTERM?
One solution I thought was to create a script which will run during Ubuntu's Shutdown and will simply send SIGTERM to my app's Java process.
But its an over-kill. LoL. No puns intended. Any other suggestions will be greatly appreciated.
Thanks.
Bookmarks