In order to fix 4755829 and 4784574, JVM_RegisterSignal() has been changed
to return -1 if original handler for SIGINT/HUP/TERM is SIG_IGN. This,
however, introduced bug 4850355, because sun.misc.Signal.handle() will
throw an IllegalArgumentException if JVM_RegisterSignal() returns -1, and
the exception will interrupt normal signal registion in Terminator.java.
So, JVM_RegisterSignal() was changed to return 1 instead. Please see the
comments section of bug 4850355 for detailed discussions.
Anyway, here is a proposal to fix these problems in Tiger:
1. change sun.misc.Signal.handle():
public static synchronized SignalHandler handle(Signal sig,
SignalHandler handler)
so it can query current signal handler without installing a
new one:
if "handler" is non-null, register it and return old handler;
if "handler" is null, return old handler
2. This, of course, will require support in JVM_RegisterSignal():
void* JVM_RegisterSignal(jint sig, void* handler)
Currently, we set new signal handler to:
SIG_DFL (0), if handler is 0
SIG_IGN (1), if handler is 1
JVM handler (os::user_handler()), if handler is 2
I'd like to add another special value (-1). If handler is -1,
all JVM_RegisterSignal does is to return current signal handler.
3. With this, we can remove the os::Solaris/Linux::is_sig_ignored()
check from JVM_RegisterSignal() and add the check to Terminator.setup():
static void setup() {
[...]
handler = sh;
+ String sigs[] = { "HUP", "INT", "TERM" };
+ for (int i = 0; i < sigs.length; i++) {
+ try {
+ Signal sig = new Signal(sigs[i]);
+ if (Signal.handle(sig, null) != SignalHandler.SIG_IGN)
+ Signal.handle(sig, sh);
+ } catch (IllegalArgumentException e) {
+ }
+ }
- try {
- Signal.handle(new Signal("HUP"), sh);
- Signal.handle(new Signal("INT"), sh);
- Signal.handle(new Signal("TERM"), sh);
- } catch (IllegalArgumentException e) {
- // When -Xrs is specified the user is responsible for
- // ensuring that shutdown hooks are run by calling
- // System.exit()
- }
}
to return -1 if original handler for SIGINT/HUP/TERM is SIG_IGN. This,
however, introduced bug 4850355, because sun.misc.Signal.handle() will
throw an IllegalArgumentException if JVM_RegisterSignal() returns -1, and
the exception will interrupt normal signal registion in Terminator.java.
So, JVM_RegisterSignal() was changed to return 1 instead. Please see the
comments section of bug 4850355 for detailed discussions.
Anyway, here is a proposal to fix these problems in Tiger:
1. change sun.misc.Signal.handle():
public static synchronized SignalHandler handle(Signal sig,
SignalHandler handler)
so it can query current signal handler without installing a
new one:
if "handler" is non-null, register it and return old handler;
if "handler" is null, return old handler
2. This, of course, will require support in JVM_RegisterSignal():
void* JVM_RegisterSignal(jint sig, void* handler)
Currently, we set new signal handler to:
SIG_DFL (0), if handler is 0
SIG_IGN (1), if handler is 1
JVM handler (os::user_handler()), if handler is 2
I'd like to add another special value (-1). If handler is -1,
all JVM_RegisterSignal does is to return current signal handler.
3. With this, we can remove the os::Solaris/Linux::is_sig_ignored()
check from JVM_RegisterSignal() and add the check to Terminator.setup():
static void setup() {
[...]
handler = sh;
+ String sigs[] = { "HUP", "INT", "TERM" };
+ for (int i = 0; i < sigs.length; i++) {
+ try {
+ Signal sig = new Signal(sigs[i]);
+ if (Signal.handle(sig, null) != SignalHandler.SIG_IGN)
+ Signal.handle(sig, sh);
+ } catch (IllegalArgumentException e) {
+ }
+ }
- try {
- Signal.handle(new Signal("HUP"), sh);
- Signal.handle(new Signal("INT"), sh);
- Signal.handle(new Signal("TERM"), sh);
- } catch (IllegalArgumentException e) {
- // When -Xrs is specified the user is responsible for
- // ensuring that shutdown hooks are run by calling
- // System.exit()
- }
}