JVM Signal Handling on NT and HP-Unix

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

[1321 byte] By [kdastgir] at [2007-9-26 4:52:38]
# 1

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

signumsignameNameDescription

0SIGNULLNullCheck access to pid

1SIGHUPHangup Terminate; can be trapped

2SIGINTInterruptTerminate; can be trapped

3SIGQUITQuitTerminate with core dump; can be trapped

9SIGKILLKillForced termination; cannot be trapped

15SIGTERMTerminateTerminate; can be trapped

24SIGSTOPStopPause the process; cannot be trapped

25SIGTSTPTerminal stopPause the process; can be trapped

26SIGCONTContinueRun 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.

edwardfan at 2007-6-29 18:45:04 > top of Java-index,Java HotSpot Virtual Machine,Specifications...