8134537: Much nearly duplicated code for sun.misc.Signal support
authorcoleenp
Fri, 18 May 2018 08:47:42 -0400
changeset 50177 9806f23d5e5e
parent 50176 0cc29ebee3f9
child 50178 7b0291382aff
8134537: Much nearly duplicated code for sun.misc.Signal support Summary: merged jvm_<os>.cpp into jvm_posix.cpp Reviewed-by: dholmes, stuefe
src/hotspot/os/aix/jvm_aix.cpp
src/hotspot/os/aix/os_aix.cpp
src/hotspot/os/aix/os_aix.hpp
src/hotspot/os/bsd/jvm_bsd.cpp
src/hotspot/os/bsd/os_bsd.cpp
src/hotspot/os/bsd/os_bsd.hpp
src/hotspot/os/linux/jvm_linux.cpp
src/hotspot/os/linux/os_linux.cpp
src/hotspot/os/linux/os_linux.hpp
src/hotspot/os/posix/jvm_posix.cpp
src/hotspot/os/posix/os_posix.cpp
src/hotspot/os/posix/os_posix.hpp
src/hotspot/os/solaris/jvm_solaris.cpp
src/hotspot/os/solaris/os_solaris.cpp
src/hotspot/os/solaris/os_solaris.hpp
--- a/src/hotspot/os/aix/jvm_aix.cpp	Fri May 18 10:59:04 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2013 SAP SE. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "jvm.h"
-#include "runtime/interfaceSupport.inline.hpp"
-#include "runtime/osThread.hpp"
-
-#include <signal.h>
-
-
-// sun.misc.Signal ///////////////////////////////////////////////////////////
-// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
-/*
- * This function is included primarily as a debugging aid. If Java is
- * running in a console window, then pressing <CTRL-\\> will cause
- * the current state of all active threads and monitors to be written
- * to the console window.
- */
-
-JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
-  // Copied from classic vm
-  // signals_md.c       1.4 98/08/23
-  void* newHandler = handler == (void *)2
-                   ? os::user_handler()
-                   : handler;
-  switch (sig) {
-    /* The following are already used by the VM. */
-    case SIGFPE:
-    case SIGILL:
-    case SIGSEGV:
-
-    /* The following signal is used by the VM to dump thread stacks unless
-       ReduceSignalUsage is set, in which case the user is allowed to set
-       his own _native_ handler for this signal; thus, in either case,
-       we do not allow JVM_RegisterSignal to change the handler. */
-    case BREAK_SIGNAL:
-      return (void *)-1;
-
-    /* The following signals are used for Shutdown Hooks support. However, if
-       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
-       System.exit(), Java is not allowed to use these signals, and the the
-       user is allowed to set his own _native_ handler for these signals and
-       invoke System.exit() as needed. Terminator.setup() is avoiding
-       registration of these signals when -Xrs is present.
-       - If the HUP signal is ignored (from the nohup) command, then Java
-         is not allowed to use this signal.
-     */
-
-    case SHUTDOWN1_SIGNAL:
-    case SHUTDOWN2_SIGNAL:
-    case SHUTDOWN3_SIGNAL:
-      if (ReduceSignalUsage) return (void*)-1;
-      if (os::Aix::is_sig_ignored(sig)) return (void*)1;
-  }
-
-  void* oldHandler = os::signal(sig, newHandler);
-  if (oldHandler == os::user_handler()) {
-      return (void *)2;
-  } else {
-      return oldHandler;
-  }
-JVM_END
-
-
-JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
-  if (ReduceSignalUsage) {
-    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,
-    // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since
-    // no handler for them is actually registered in JVM or via
-    // JVM_RegisterSignal.
-    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-        sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {
-      return JNI_FALSE;
-    }
-  }
-  else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-            sig == SHUTDOWN3_SIGNAL) && os::Aix::is_sig_ignored(sig)) {
-    // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL
-    // is ignored, since no handler for them is actually registered in JVM
-    // or via JVM_RegisterSignal.
-    // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL
-    return JNI_FALSE;
-  }
-
-  os::signal_raise(sig);
-  return JNI_TRUE;
-JVM_END
-
--- a/src/hotspot/os/aix/os_aix.cpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/aix/os_aix.cpp	Fri May 18 08:47:42 2018 -0400
@@ -622,18 +622,6 @@
 debug_only(static bool signal_sets_initialized = false);
 static sigset_t unblocked_sigs, vm_sigs;
 
-bool os::Aix::is_sig_ignored(int sig) {
-  struct sigaction oact;
-  sigaction(sig, (struct sigaction*)NULL, &oact);
-  void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*, oact.sa_sigaction)
-    : CAST_FROM_FN_PTR(void*, oact.sa_handler);
-  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
-    return true;
-  } else {
-    return false;
-  }
-}
-
 void os::Aix::signal_sets_init() {
   // Should also have an assertion stating we are still single-threaded.
   assert(!signal_sets_initialized, "Already initialized");
@@ -659,13 +647,13 @@
   sigaddset(&unblocked_sigs, SR_signum);
 
   if (!ReduceSignalUsage) {
-   if (!os::Aix::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
+   if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
      sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
    }
-   if (!os::Aix::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
+   if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
      sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
    }
-   if (!os::Aix::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
+   if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
      sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
    }
   }
--- a/src/hotspot/os/aix/os_aix.hpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/aix/os_aix.hpp	Fri May 18 08:47:42 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2013, 2016 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -121,7 +121,6 @@
   static void signal_sets_init();
   static void install_signal_handlers();
   static void set_signal_handler(int, bool);
-  static bool is_sig_ignored(int sig);
 
   static sigset_t* unblocked_signals();
   static sigset_t* vm_signals();
--- a/src/hotspot/os/bsd/jvm_bsd.cpp	Fri May 18 10:59:04 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "jvm.h"
-#include "runtime/interfaceSupport.inline.hpp"
-#include "runtime/osThread.hpp"
-
-#include <signal.h>
-
-
-// sun.misc.Signal ///////////////////////////////////////////////////////////
-// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
-/*
- * This function is included primarily as a debugging aid. If Java is
- * running in a console window, then pressing <CTRL-\\> will cause
- * the current state of all active threads and monitors to be written
- * to the console window.
- */
-
-JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
-  // Copied from classic vm
-  // signals_md.c       1.4 98/08/23
-  void* newHandler = handler == (void *)2
-                   ? os::user_handler()
-                   : handler;
-  switch (sig) {
-    /* The following are already used by the VM. */
-    case SIGFPE:
-    case SIGILL:
-    case SIGSEGV:
-
-#if defined(__APPLE__)
-    /* On Darwin, memory access errors commonly results in SIGBUS instead
-     * of SIGSEGV. */
-    case SIGBUS:
-#endif
-
-    /* The following signal is used by the VM to dump thread stacks unless
-       ReduceSignalUsage is set, in which case the user is allowed to set
-       his own _native_ handler for this signal; thus, in either case,
-       we do not allow JVM_RegisterSignal to change the handler. */
-    case BREAK_SIGNAL:
-      return (void *)-1;
-
-    /* The following signals are used for Shutdown Hooks support. However, if
-       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
-       System.exit(), Java is not allowed to use these signals, and the the
-       user is allowed to set his own _native_ handler for these signals and
-       invoke System.exit() as needed. Terminator.setup() is avoiding
-       registration of these signals when -Xrs is present.
-       - If the HUP signal is ignored (from the nohup) command, then Java
-         is not allowed to use this signal.
-     */
-
-    case SHUTDOWN1_SIGNAL:
-    case SHUTDOWN2_SIGNAL:
-    case SHUTDOWN3_SIGNAL:
-      if (ReduceSignalUsage) return (void*)-1;
-      if (os::Bsd::is_sig_ignored(sig)) return (void*)1;
-  }
-
-  void* oldHandler = os::signal(sig, newHandler);
-  if (oldHandler == os::user_handler()) {
-      return (void *)2;
-  } else {
-      return oldHandler;
-  }
-JVM_END
-
-
-JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
-  if (ReduceSignalUsage) {
-    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,
-    // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since
-    // no handler for them is actually registered in JVM or via
-    // JVM_RegisterSignal.
-    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-        sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {
-      return JNI_FALSE;
-    }
-  }
-  else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-            sig == SHUTDOWN3_SIGNAL) && os::Bsd::is_sig_ignored(sig)) {
-    // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL
-    // is ignored, since no handler for them is actually registered in JVM
-    // or via JVM_RegisterSignal.
-    // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL
-    return JNI_FALSE;
-  }
-
-  os::signal_raise(sig);
-  return JNI_TRUE;
-JVM_END
-
--- a/src/hotspot/os/bsd/os_bsd.cpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Fri May 18 08:47:42 2018 -0400
@@ -533,18 +533,6 @@
 debug_only(static bool signal_sets_initialized = false);
 static sigset_t unblocked_sigs, vm_sigs;
 
-bool os::Bsd::is_sig_ignored(int sig) {
-  struct sigaction oact;
-  sigaction(sig, (struct sigaction*)NULL, &oact);
-  void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
-                                 : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
-  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
-    return true;
-  } else {
-    return false;
-  }
-}
-
 void os::Bsd::signal_sets_init() {
   // Should also have an assertion stating we are still single-threaded.
   assert(!signal_sets_initialized, "Already initialized");
@@ -569,14 +557,14 @@
   sigaddset(&unblocked_sigs, SR_signum);
 
   if (!ReduceSignalUsage) {
-    if (!os::Bsd::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
 
     }
-    if (!os::Bsd::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
     }
-    if (!os::Bsd::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
     }
   }
--- a/src/hotspot/os/bsd/os_bsd.hpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/bsd/os_bsd.hpp	Fri May 18 08:47:42 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,7 +103,6 @@
   static void signal_sets_init();
   static void install_signal_handlers();
   static void set_signal_handler(int, bool);
-  static bool is_sig_ignored(int sig);
 
   static sigset_t* unblocked_signals();
   static sigset_t* vm_signals();
--- a/src/hotspot/os/linux/jvm_linux.cpp	Fri May 18 10:59:04 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "jvm.h"
-#include "runtime/interfaceSupport.inline.hpp"
-#include "runtime/osThread.hpp"
-
-#include <signal.h>
-
-
-// sun.misc.Signal ///////////////////////////////////////////////////////////
-// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
-/*
- * This function is included primarily as a debugging aid. If Java is
- * running in a console window, then pressing <CTRL-\\> will cause
- * the current state of all active threads and monitors to be written
- * to the console window.
- */
-
-JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
-  // Copied from classic vm
-  // signals_md.c       1.4 98/08/23
-  void* newHandler = handler == (void *)2
-                   ? os::user_handler()
-                   : handler;
-  switch (sig) {
-    /* The following are already used by the VM. */
-    case SIGFPE:
-    case SIGILL:
-    case SIGSEGV:
-
-    /* The following signal is used by the VM to dump thread stacks unless
-       ReduceSignalUsage is set, in which case the user is allowed to set
-       his own _native_ handler for this signal; thus, in either case,
-       we do not allow JVM_RegisterSignal to change the handler. */
-    case BREAK_SIGNAL:
-      return (void *)-1;
-
-    /* The following signals are used for Shutdown Hooks support. However, if
-       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
-       System.exit(), Java is not allowed to use these signals, and the the
-       user is allowed to set his own _native_ handler for these signals and
-       invoke System.exit() as needed. Terminator.setup() is avoiding
-       registration of these signals when -Xrs is present.
-       - If the HUP signal is ignored (from the nohup) command, then Java
-         is not allowed to use this signal.
-     */
-
-    case SHUTDOWN1_SIGNAL:
-    case SHUTDOWN2_SIGNAL:
-    case SHUTDOWN3_SIGNAL:
-      if (ReduceSignalUsage) return (void*)-1;
-      if (os::Linux::is_sig_ignored(sig)) return (void*)1;
-  }
-
-  void* oldHandler = os::signal(sig, newHandler);
-  if (oldHandler == os::user_handler()) {
-      return (void *)2;
-  } else {
-      return oldHandler;
-  }
-JVM_END
-
-
-JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
-  if (ReduceSignalUsage) {
-    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,
-    // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since
-    // no handler for them is actually registered in JVM or via
-    // JVM_RegisterSignal.
-    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-        sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {
-      return JNI_FALSE;
-    }
-  }
-  else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-            sig == SHUTDOWN3_SIGNAL) && os::Linux::is_sig_ignored(sig)) {
-    // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL
-    // is ignored, since no handler for them is actually registered in JVM
-    // or via JVM_RegisterSignal.
-    // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL
-    return JNI_FALSE;
-  }
-
-  os::signal_raise(sig);
-  return JNI_TRUE;
-JVM_END
-
--- a/src/hotspot/os/linux/os_linux.cpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/linux/os_linux.cpp	Fri May 18 08:47:42 2018 -0400
@@ -425,18 +425,6 @@
 debug_only(static bool signal_sets_initialized = false);
 static sigset_t unblocked_sigs, vm_sigs;
 
-bool os::Linux::is_sig_ignored(int sig) {
-  struct sigaction oact;
-  sigaction(sig, (struct sigaction*)NULL, &oact);
-  void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
-                                 : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
-  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
-    return true;
-  } else {
-    return false;
-  }
-}
-
 void os::Linux::signal_sets_init() {
   // Should also have an assertion stating we are still single-threaded.
   assert(!signal_sets_initialized, "Already initialized");
@@ -464,13 +452,13 @@
   sigaddset(&unblocked_sigs, SR_signum);
 
   if (!ReduceSignalUsage) {
-    if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
     }
-    if (!os::Linux::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
     }
-    if (!os::Linux::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
     }
   }
--- a/src/hotspot/os/linux/os_linux.hpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/linux/os_linux.hpp	Fri May 18 08:47:42 2018 -0400
@@ -160,7 +160,6 @@
   static void signal_sets_init();
   static void install_signal_handlers();
   static void set_signal_handler(int, bool);
-  static bool is_sig_ignored(int sig);
 
   static sigset_t* unblocked_signals();
   static sigset_t* vm_signals();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/os/posix/jvm_posix.cpp	Fri May 18 08:47:42 2018 -0400
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "jvm.h"
+#include "runtime/interfaceSupport.inline.hpp"
+#include "runtime/osThread.hpp"
+
+#include <signal.h>
+
+
+// jdk.internal.misc.Signal ///////////////////////////////////////////////////////////
+// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
+/*
+ * This function is included primarily as a debugging aid. If Java is
+ * running in a console window, then pressing <CTRL-\\> will cause
+ * the current state of all active threads and monitors to be written
+ * to the console window.
+ */
+
+JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
+  // Copied from classic vm
+  // signals_md.c       1.4 98/08/23
+  void* newHandler = handler == (void *)2
+                   ? os::user_handler()
+                   : handler;
+  switch (sig) {
+    /* The following are already used by the VM. */
+    case SIGFPE:
+    case SIGILL:
+    case SIGSEGV:
+
+#if defined(__APPLE__)
+    /* On Darwin, memory access errors commonly results in SIGBUS instead
+     * of SIGSEGV. */
+    case SIGBUS:
+#endif
+
+    /* The following signal is used by the VM to dump thread stacks unless
+       ReduceSignalUsage is set, in which case the user is allowed to set
+       his own _native_ handler for this signal; thus, in either case,
+       we do not allow JVM_RegisterSignal to change the handler. */
+    case BREAK_SIGNAL:
+      return (void *)-1;
+
+    /* The following signals are used for Shutdown Hooks support. However, if
+       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
+       System.exit(), Java is not allowed to use these signals, and the the
+       user is allowed to set his own _native_ handler for these signals and
+       invoke System.exit() as needed. Terminator.setup() is avoiding
+       registration of these signals when -Xrs is present.
+       - If the HUP signal is ignored (from the nohup) command, then Java
+         is not allowed to use this signal.
+     */
+
+    case SHUTDOWN1_SIGNAL:
+    case SHUTDOWN2_SIGNAL:
+    case SHUTDOWN3_SIGNAL:
+      if (ReduceSignalUsage) return (void*)-1;
+      if (os::Posix::is_sig_ignored(sig)) return (void*)1;
+  }
+
+  void* oldHandler = os::signal(sig, newHandler);
+  if (oldHandler == os::user_handler()) {
+      return (void *)2;
+  } else {
+      return oldHandler;
+  }
+JVM_END
+
+
+JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
+  if (ReduceSignalUsage) {
+    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,
+    // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since
+    // no handler for them is actually registered in JVM or via
+    // JVM_RegisterSignal.
+    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
+        sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {
+      return JNI_FALSE;
+    }
+  }
+  else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
+            sig == SHUTDOWN3_SIGNAL) && os::Posix::is_sig_ignored(sig)) {
+    // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL
+    // is ignored, since no handler for them is actually registered in JVM
+    // or via JVM_RegisterSignal.
+    // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL
+    return JNI_FALSE;
+  }
+
+  os::signal_raise(sig);
+  return JNI_TRUE;
+JVM_END
+
--- a/src/hotspot/os/posix/os_posix.cpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/posix/os_posix.cpp	Fri May 18 08:47:42 2018 -0400
@@ -926,6 +926,18 @@
 #endif
 }
 
+bool os::Posix::is_sig_ignored(int sig) {
+  struct sigaction oact;
+  sigaction(sig, (struct sigaction*)NULL, &oact);
+  void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
+                                 : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
+  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
 // Returns:
 // NULL for an invalid signal number
 // "SIG<num>" for a valid but unknown signal number
--- a/src/hotspot/os/posix/os_posix.hpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/posix/os_posix.hpp	Fri May 18 08:47:42 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,6 +64,7 @@
 
   // Returns true if signal is valid.
   static bool is_valid_signal(int sig);
+  static bool is_sig_ignored(int sig);
 
   // Helper function, returns a string (e.g. "SIGILL") for a signal.
   // Returned string is a constant. For unknown signals "UNKNOWN" is returned.
--- a/src/hotspot/os/solaris/jvm_solaris.cpp	Fri May 18 10:59:04 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "jvm.h"
-#include "runtime/interfaceSupport.inline.hpp"
-#include "runtime/osThread.hpp"
-
-#include <signal.h>
-
-// sun.misc.Signal ///////////////////////////////////////////////////////////
-// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
-/*
- * This function is included primarily as a debugging aid. If Java is
- * running in a console window, then pressing <CTRL-\\> will cause
- * the current state of all active threads and monitors to be written
- * to the console window.
- */
-
-JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
-  // Copied from classic vm
-  // signals_md.c       1.4 98/08/23
-  void* newHandler = handler == (void *)2
-                   ? os::user_handler()
-                   : handler;
-  switch (sig) {
-    /* The following are already used by the VM. */
-    case SIGFPE:
-    case SIGILL:
-    case SIGSEGV:
-
-    /* The following signal is used by the VM to dump thread stacks unless
-       ReduceSignalUsage is set, in which case the user is allowed to set
-       his own _native_ handler for this signal; thus, in either case,
-       we do not allow JVM_RegisterSignal to change the handler. */
-    case BREAK_SIGNAL:
-      return (void *)-1;
-
-    /* The following signals are used for Shutdown Hooks support. However, if
-       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
-       System.exit(), Java is not allowed to use these signals, and the the
-       user is allowed to set his own _native_ handler for these signals and
-       invoke System.exit() as needed. Terminator.setup() is avoiding
-       registration of these signals when -Xrs is present.
-       - If the HUP signal is ignored (from the nohup) command, then Java
-         is not allowed to use this signal.
-     */
-    case SHUTDOWN1_SIGNAL:
-    case SHUTDOWN2_SIGNAL:
-    case SHUTDOWN3_SIGNAL:
-      if (ReduceSignalUsage) return (void*)-1;
-      if (os::Solaris::is_sig_ignored(sig)) return (void*)1;
-  }
-
-  void* oldHandler = os::signal(sig, newHandler);
-  if (oldHandler == os::user_handler()) {
-      return (void *)2;
-  } else {
-      return oldHandler;
-  }
-JVM_END
-
-
-JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
-  if (ReduceSignalUsage) {
-    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,
-    // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since
-    // no handler for them is actually registered in JVM or via
-    // JVM_RegisterSignal.
-    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-        sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {
-      return JNI_FALSE;
-    }
-  }
-  else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
-            sig == SHUTDOWN3_SIGNAL) && os::Solaris::is_sig_ignored(sig)) {
-    // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL
-    // is ignored, since no handler for them is actually registered in JVM
-    // or via JVM_RegisterSignal.
-    // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL
-    return JNI_FALSE;
-  }
-
-  os::signal_raise(sig);
-  return JNI_TRUE;
-JVM_END
-
--- a/src/hotspot/os/solaris/os_solaris.cpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Fri May 18 08:47:42 2018 -0400
@@ -1026,18 +1026,6 @@
 debug_only(static bool signal_sets_initialized = false);
 static sigset_t unblocked_sigs, vm_sigs;
 
-bool os::Solaris::is_sig_ignored(int sig) {
-  struct sigaction oact;
-  sigaction(sig, (struct sigaction*)NULL, &oact);
-  void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
-                                 : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
-  if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
-    return true;
-  } else {
-    return false;
-  }
-}
-
 void os::Solaris::signal_sets_init() {
   // Should also have an assertion stating we are still single-threaded.
   assert(!signal_sets_initialized, "Already initialized");
@@ -1062,13 +1050,13 @@
   sigaddset(&unblocked_sigs, ASYNC_SIGNAL);
 
   if (!ReduceSignalUsage) {
-    if (!os::Solaris::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
     }
-    if (!os::Solaris::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
     }
-    if (!os::Solaris::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
+    if (!os::Posix::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
     }
   }
--- a/src/hotspot/os/solaris/os_solaris.hpp	Fri May 18 10:59:04 2018 +0200
+++ b/src/hotspot/os/solaris/os_solaris.hpp	Fri May 18 08:47:42 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -188,7 +188,6 @@
   static void install_signal_handlers();
   static void set_signal_handler(int sig, bool set_installed, bool oktochain);
   static void init_signal_mem();
-  static bool is_sig_ignored(int sig);
   static void set_our_sigflags(int, int);
   static int get_our_sigflags(int);