JVM Signal Handling on NT and HP-Unix

Advertisement
Hi
I'm trying to catch various JVM shutdown signals in my application so that the application can do some clean-up before shutting down. Here is the code that i've written...
sun.misc.SignalHandler jvmSignalHandler = new sun.misc.SignalHandler()
public void handle(sun.misc.Signal sig)
// Do some cleanup
// Call handler on interrupt signal (CTRL-C)
sun.misc.Signal.handle(new sun.misc.Signal("INT"), jvmSignalHandler);
// Call handler on terminate signal
sun.misc.Signal.handle(new sun.misc.Signal("TERM"), jvmSignalHandler);
// Call handler on abort signal
sun.misc.Signal.handle(new sun.misc.Signal("ABRT"), jvmSignalHandler);
If i run this process on NT in a dos box, the applicatin behaves fine by responding to all these signals...
e.g. If i press CTRL-C (INT), or i close the dos box (TERM), or i shutdown NT (ABRT).
However on UP-Unix, i tried kill -2 (TERM), kill -6 (ABRT) and kill -15 (INT)... Out of these, only kill -6 (ABRT) works, while the others just "kill" the application and there is no clean-up. Can anyone help if i need to use any other codes on HP-Unix, or do i need to catch any other signals in my application.
Thanks in advance
Regards
Kashif
Advertisement

Replay

Hope the following info(from HP-UX $man kill) is useful to you.
Signal Names and Numbers
The following table describes a few of the more common signals that
can be useful from a terminal. For a complete list and a full
description, see the header file <signal.h> and the manual entry
signal(5).
signum signame Name Description
0 SIGNULL Null Check access to pid
1 SIGHUP Hangup Terminate; can be trapped
2 SIGINT Interrupt Terminate; can be trapped
3 SIGQUIT Quit Terminate with core dump; can be trapped
9 SIGKILL Kill Forced termination; cannot be trapped
15 SIGTERM Terminate Terminate; can be trapped
24 SIGSTOP Stop Pause the process; cannot be trapped
25 SIGTSTP Terminal stop Pause the process; can be trapped
26 SIGCONT Continue Run a stopped process
BTW, do you have JavaDoc for sun.misc.Signal class in hand? I havn't. I'm not sure the name-rule for signals between HP-UX and Windows is same or not.