8293466: libjsig should ignore non-modifying sigaction calls
Reviewed-by: manc, dholmes
This commit is contained in:
parent
b6ff8fa307
commit
b1ed40a87a
@ -248,17 +248,28 @@ JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *
|
|||||||
signal_unlock();
|
signal_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (jvm_signal_installing) {
|
} else if (jvm_signal_installing) {
|
||||||
/* jvm is installing its signal handlers. Install the new
|
/* jvm is installing its signal handlers.
|
||||||
* handlers and save the old ones. */
|
* - if this is a modifying sigaction call, we install a new signal handler and store the old one
|
||||||
|
* as chained signal handler.
|
||||||
|
* - if this is a non-modifying sigaction call, we don't change any state; we just return the existing
|
||||||
|
* signal handler in the system (not the stored one).
|
||||||
|
* This works under the assumption that there is only one modifying sigaction call for a specific signal
|
||||||
|
* within the JVM_begin_signal_setting-JVM_end_signal_setting-window. There can be any number of non-modifying
|
||||||
|
* calls, but they will only return the expected preexisting handler if executed before the modifying call.
|
||||||
|
*/
|
||||||
res = call_os_sigaction(sig, act, &oldAct);
|
res = call_os_sigaction(sig, act, &oldAct);
|
||||||
sact[sig] = oldAct;
|
if (res == 0) {
|
||||||
if (oact != NULL) {
|
if (act != NULL) {
|
||||||
*oact = oldAct;
|
/* store pre-existing handler as chained handler */
|
||||||
|
sact[sig] = oldAct;
|
||||||
|
/* Record the signals used by jvm. */
|
||||||
|
sigaddset(&jvmsigs, sig);
|
||||||
|
}
|
||||||
|
if (oact != NULL) {
|
||||||
|
*oact = oldAct;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Record the signals used by jvm. */
|
|
||||||
sigaddset(&jvmsigs, sig);
|
|
||||||
|
|
||||||
signal_unlock();
|
signal_unlock();
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user