61 ReduceSignalUsage is set, in which case the user is allowed to set 62 his own _native_ handler for this signal; thus, in either case, 63 we do not allow JVM_RegisterSignal to change the handler. */ 64 case BREAK_SIGNAL: 65 return (void *)-1; 66 67 /* The following signals are used for Shutdown Hooks support. However, if 68 ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via 69 System.exit(), Java is not allowed to use these signals, and the the 70 user is allowed to set his own _native_ handler for these signals and 71 invoke System.exit() as needed. Terminator.setup() is avoiding 72 registration of these signals when -Xrs is present. 73 - If the HUP signal is ignored (from the nohup) command, then Java 74 is not allowed to use this signal. 75 */ 76 77 case SHUTDOWN1_SIGNAL: 78 case SHUTDOWN2_SIGNAL: 79 case SHUTDOWN3_SIGNAL: 80 if (ReduceSignalUsage) return (void*)-1; 81 if (os::Bsd::is_sig_ignored(sig)) return (void*)1; 82 } 83 84 void* oldHandler = os::signal(sig, newHandler); 85 if (oldHandler == os::user_handler()) { 86 return (void *)2; 87 } else { 88 return oldHandler; 89 } 90 JVM_END 91 92 93 JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig)) 94 if (ReduceSignalUsage) { 95 // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL, 96 // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since 97 // no handler for them is actually registered in JVM or via 98 // JVM_RegisterSignal. 99 if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL || 100 sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) { 101 return JNI_FALSE; 102 } 103 } 104 else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL || 105 sig == SHUTDOWN3_SIGNAL) && os::Bsd::is_sig_ignored(sig)) { 106 // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL 107 // is ignored, since no handler for them is actually registered in JVM 108 // or via JVM_RegisterSignal. 109 // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL 110 return JNI_FALSE; 111 } 112 113 os::signal_raise(sig); 114 return JNI_TRUE; 115 JVM_END 116 | 61 ReduceSignalUsage is set, in which case the user is allowed to set 62 his own _native_ handler for this signal; thus, in either case, 63 we do not allow JVM_RegisterSignal to change the handler. */ 64 case BREAK_SIGNAL: 65 return (void *)-1; 66 67 /* The following signals are used for Shutdown Hooks support. However, if 68 ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via 69 System.exit(), Java is not allowed to use these signals, and the the 70 user is allowed to set his own _native_ handler for these signals and 71 invoke System.exit() as needed. Terminator.setup() is avoiding 72 registration of these signals when -Xrs is present. 73 - If the HUP signal is ignored (from the nohup) command, then Java 74 is not allowed to use this signal. 75 */ 76 77 case SHUTDOWN1_SIGNAL: 78 case SHUTDOWN2_SIGNAL: 79 case SHUTDOWN3_SIGNAL: 80 if (ReduceSignalUsage) return (void*)-1; 81 if (os::Posix::is_sig_ignored(sig)) return (void*)1; 82 } 83 84 void* oldHandler = os::signal(sig, newHandler); 85 if (oldHandler == os::user_handler()) { 86 return (void *)2; 87 } else { 88 return oldHandler; 89 } 90 JVM_END 91 92 93 JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig)) 94 if (ReduceSignalUsage) { 95 // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL, 96 // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since 97 // no handler for them is actually registered in JVM or via 98 // JVM_RegisterSignal. 99 if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL || 100 sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) { 101 return JNI_FALSE; 102 } 103 } 104 else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL || 105 sig == SHUTDOWN3_SIGNAL) && os::Posix::is_sig_ignored(sig)) { 106 // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL 107 // is ignored, since no handler for them is actually registered in JVM 108 // or via JVM_RegisterSignal. 109 // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL 110 return JNI_FALSE; 111 } 112 113 os::signal_raise(sig); 114 return JNI_TRUE; 115 JVM_END 116 |