--- old/src/hotspot/os/aix/os_aix.cpp 2019-03-05 18:14:40.170976581 +0800 +++ new/src/hotspot/os/aix/os_aix.cpp 2019-03-05 18:14:39.814608718 +0800 @@ -2996,8 +2996,6 @@ bool os::Aix::signal_handlers_are_installed = false; // For signal-chaining -struct sigaction sigact[NSIG]; -sigset_t sigs; bool os::Aix::libjsig_is_loaded = false; typedef struct sigaction *(*get_signal_t)(int); get_signal_t os::Aix::get_signal_action = NULL; @@ -3011,7 +3009,7 @@ } if (actp == NULL) { // Retrieve the preinstalled signal handler from jvm - actp = get_preinstalled_handler(sig); + actp = os::Posix::get_preinstalled_handler(sig); } return actp; @@ -3074,19 +3072,6 @@ return chained; } -struct sigaction* os::Aix::get_preinstalled_handler(int sig) { - if (sigismember(&sigs, sig)) { - return &sigact[sig]; - } - return NULL; -} - -void os::Aix::save_preinstalled_handler(int sig, struct sigaction& oldAct) { - assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); - sigact[sig] = oldAct; - sigaddset(&sigs, sig); -} - // for diagnostic int sigflags[NSIG]; @@ -3118,7 +3103,7 @@ return; } else if (UseSignalChaining) { // save the old handler in jvm - save_preinstalled_handler(sig, oldAct); + os::Posix::save_preinstalled_handler(sig, oldAct); // libjsig also interposes the sigaction() call below and saves the // old sigaction on it own. } else { @@ -3174,7 +3159,6 @@ (*begin_signal_setting)(); } - ::sigemptyset(&sigs); set_signal_handler(SIGSEGV, true); set_signal_handler(SIGPIPE, true); set_signal_handler(SIGBUS, true); --- old/src/hotspot/os/aix/os_aix.hpp 2019-03-05 18:14:41.404557647 +0800 +++ new/src/hotspot/os/aix/os_aix.hpp 2019-03-05 18:14:41.056022044 +0800 @@ -37,8 +37,6 @@ static bool libjsig_is_loaded; // libjsig that interposes sigaction(), // __sigaction(), signal() is loaded static struct sigaction *(*get_signal_action)(int); - static struct sigaction *get_preinstalled_handler(int); - static void save_preinstalled_handler(int, struct sigaction&); static void check_signal_handler(int sig); --- old/src/hotspot/os/bsd/os_bsd.cpp 2019-03-05 18:14:42.477577368 +0800 +++ new/src/hotspot/os/bsd/os_bsd.cpp 2019-03-05 18:14:42.121209504 +0800 @@ -2658,11 +2658,6 @@ bool os::Bsd::signal_handlers_are_installed = false; // For signal-chaining -struct sigaction sigact[NSIG]; -uint32_t sigs = 0; -#if (32 < NSIG-1) -#error "Not all signals can be encoded in sigs. Adapt its type!" -#endif bool os::Bsd::libjsig_is_loaded = false; typedef struct sigaction *(*get_signal_t)(int); get_signal_t os::Bsd::get_signal_action = NULL; @@ -2676,7 +2671,7 @@ } if (actp == NULL) { // Retrieve the preinstalled signal handler from jvm - actp = get_preinstalled_handler(sig); + actp = os::Posix::get_preinstalled_handler(sig); } return actp; @@ -2739,19 +2734,6 @@ return chained; } -struct sigaction* os::Bsd::get_preinstalled_handler(int sig) { - if ((((uint32_t)1 << (sig-1)) & sigs) != 0) { - return &sigact[sig]; - } - return NULL; -} - -void os::Bsd::save_preinstalled_handler(int sig, struct sigaction& oldAct) { - assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); - sigact[sig] = oldAct; - sigs |= (uint32_t)1 << (sig-1); -} - // for diagnostic int sigflags[NSIG]; @@ -2783,7 +2765,7 @@ return; } else if (UseSignalChaining) { // save the old handler in jvm - save_preinstalled_handler(sig, oldAct); + os::Posix::save_preinstalled_handler(sig, oldAct); // libjsig also interposes the sigaction() call below and saves the // old sigaction on it own. } else { --- old/src/hotspot/os/bsd/os_bsd.hpp 2019-03-05 18:14:43.679829391 +0800 +++ new/src/hotspot/os/bsd/os_bsd.hpp 2019-03-05 18:14:43.327377658 +0800 @@ -37,8 +37,6 @@ static bool libjsig_is_loaded; // libjsig that interposes sigaction(), // __sigaction(), signal() is loaded static struct sigaction *(*get_signal_action)(int); - static struct sigaction *get_preinstalled_handler(int); - static void save_preinstalled_handler(int, struct sigaction&); static void check_signal_handler(int sig); --- old/src/hotspot/os/linux/os_linux.cpp 2019-03-05 18:14:44.745016851 +0800 +++ new/src/hotspot/os/linux/os_linux.cpp 2019-03-05 18:14:44.384732857 +0800 @@ -4463,11 +4463,6 @@ bool os::Linux::signal_handlers_are_installed = false; // For signal-chaining -struct sigaction sigact[NSIG]; -uint64_t sigs = 0; -#if (64 < NSIG-1) -#error "Not all signals can be encoded in sigs. Adapt its type!" -#endif bool os::Linux::libjsig_is_loaded = false; typedef struct sigaction *(*get_signal_t)(int); get_signal_t os::Linux::get_signal_action = NULL; @@ -4481,7 +4476,7 @@ } if (actp == NULL) { // Retrieve the preinstalled signal handler from jvm - actp = get_preinstalled_handler(sig); + actp = os::Posix::get_preinstalled_handler(sig); } return actp; @@ -4545,19 +4540,6 @@ return chained; } -struct sigaction* os::Linux::get_preinstalled_handler(int sig) { - if ((((uint64_t)1 << (sig-1)) & sigs) != 0) { - return &sigact[sig]; - } - return NULL; -} - -void os::Linux::save_preinstalled_handler(int sig, struct sigaction& oldAct) { - assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); - sigact[sig] = oldAct; - sigs |= (uint64_t)1 << (sig-1); -} - // for diagnostic int sigflags[NSIG]; @@ -4589,7 +4571,7 @@ return; } else if (UseSignalChaining) { // save the old handler in jvm - save_preinstalled_handler(sig, oldAct); + os::Posix::save_preinstalled_handler(sig, oldAct); // libjsig also interposes the sigaction() call below and saves the // old sigaction on it own. } else { --- old/src/hotspot/os/linux/os_linux.hpp 2019-03-05 18:14:46.029507612 +0800 +++ new/src/hotspot/os/linux/os_linux.hpp 2019-03-05 18:14:45.680972009 +0800 @@ -38,8 +38,6 @@ static bool libjsig_is_loaded; // libjsig that interposes sigaction(), // __sigaction(), signal() is loaded static struct sigaction *(*get_signal_action)(int); - static struct sigaction *get_preinstalled_handler(int); - static void save_preinstalled_handler(int, struct sigaction&); static void check_signal_handler(int sig); --- old/src/hotspot/os/posix/os_posix.cpp 2019-03-05 18:14:47.106443463 +0800 +++ new/src/hotspot/os/posix/os_posix.cpp 2019-03-05 18:14:46.753991730 +0800 @@ -1644,6 +1644,24 @@ } } +#ifndef SOLARIS +sigset_t sigs; +struct sigaction sigact[NSIG]; + +struct sigaction* os::Posix::get_preinstalled_handler(int sig) { + if (sigismember(&sigs, sig)) { + return &sigact[sig]; + } + return NULL; +} + +void os::Posix::save_preinstalled_handler(int sig, struct sigaction& oldAct) { + assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); + sigact[sig] = oldAct; + sigaddset(&sigs, sig); +} +#endif + // Not all POSIX types and API's are available on all notionally "posix" // platforms. If we have build-time support then we will check for actual // runtime support via dlopen/dlsym lookup. This allows for running on an @@ -1754,6 +1772,7 @@ (_pthread_condattr_setclock != NULL ? "" : " not")); log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with %s", _use_clock_monotonic_condattr ? "CLOCK_MONOTONIC" : "the default clock"); + sigemptyset(&sigs); #endif // !SOLARIS } @@ -1768,6 +1787,7 @@ log_info(os)("Use of CLOCK_MONOTONIC is not supported"); log_info(os)("Use of pthread_condattr_setclock is not supported"); log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with the default clock"); + sigemptyset(&sigs); #endif // !SOLARIS } --- old/src/hotspot/os/posix/os_posix.hpp 2019-03-05 18:14:48.249953531 +0800 +++ new/src/hotspot/os/posix/os_posix.hpp 2019-03-05 18:14:47.901417928 +0800 @@ -117,6 +117,9 @@ // effective gid, or if given uid is root. static bool matches_effective_uid_and_gid_or_root(uid_t uid, gid_t gid); + static struct sigaction *get_preinstalled_handler(int); + static void save_preinstalled_handler(int, struct sigaction&); + static void print_umask(outputStream* st, mode_t umsk); static void print_user_info(outputStream* st);