1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/os/solaris/vm/jvm_solaris.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,150 @@ 1.4 +/* 1.5 + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "prims/jvm.h" 1.30 +#include "runtime/interfaceSupport.hpp" 1.31 +#include "runtime/osThread.hpp" 1.32 + 1.33 +#include <signal.h> 1.34 + 1.35 +// sun.misc.Signal /////////////////////////////////////////////////////////// 1.36 +// Signal code is mostly copied from classic vm, signals_md.c 1.4 98/08/23 1.37 +/* 1.38 + * This function is included primarily as a debugging aid. If Java is 1.39 + * running in a console window, then pressing <CTRL-\\> will cause 1.40 + * the current state of all active threads and monitors to be written 1.41 + * to the console window. 1.42 + */ 1.43 + 1.44 +JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler)) 1.45 + // Copied from classic vm 1.46 + // signals_md.c 1.4 98/08/23 1.47 + void* newHandler = handler == (void *)2 1.48 + ? os::user_handler() 1.49 + : handler; 1.50 + switch (sig) { 1.51 + /* The following are already used by the VM. */ 1.52 + case SIGFPE: 1.53 + case SIGILL: 1.54 + case SIGSEGV: 1.55 + 1.56 + /* The following signal is used by the VM to dump thread stacks unless 1.57 + ReduceSignalUsage is set, in which case the user is allowed to set 1.58 + his own _native_ handler for this signal; thus, in either case, 1.59 + we do not allow JVM_RegisterSignal to change the handler. */ 1.60 + case BREAK_SIGNAL: 1.61 + return (void *)-1; 1.62 + 1.63 + /* The following signals are used for Shutdown Hooks support. However, if 1.64 + ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via 1.65 + System.exit(), Java is not allowed to use these signals, and the the 1.66 + user is allowed to set his own _native_ handler for these signals and 1.67 + invoke System.exit() as needed. Terminator.setup() is avoiding 1.68 + registration of these signals when -Xrs is present. 1.69 + - If the HUP signal is ignored (from the nohup) command, then Java 1.70 + is not allowed to use this signal. 1.71 + */ 1.72 + case SHUTDOWN1_SIGNAL: 1.73 + case SHUTDOWN2_SIGNAL: 1.74 + case SHUTDOWN3_SIGNAL: 1.75 + if (ReduceSignalUsage) return (void*)-1; 1.76 + if (os::Solaris::is_sig_ignored(sig)) return (void*)1; 1.77 + } 1.78 + 1.79 + /* Check parameterized signals. Don't allow sharing of our interrupt signal */ 1.80 + if (sig == os::Solaris::SIGinterrupt()) { 1.81 + return (void *)-1; 1.82 + } 1.83 + 1.84 + void* oldHandler = os::signal(sig, newHandler); 1.85 + if (oldHandler == os::user_handler()) { 1.86 + return (void *)2; 1.87 + } else { 1.88 + return oldHandler; 1.89 + } 1.90 +JVM_END 1.91 + 1.92 + 1.93 +JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig)) 1.94 + if (ReduceSignalUsage) { 1.95 + // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL, 1.96 + // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since 1.97 + // no handler for them is actually registered in JVM or via 1.98 + // JVM_RegisterSignal. 1.99 + if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL || 1.100 + sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) { 1.101 + return JNI_FALSE; 1.102 + } 1.103 + } 1.104 + else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL || 1.105 + sig == SHUTDOWN3_SIGNAL) && os::Solaris::is_sig_ignored(sig)) { 1.106 + // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL 1.107 + // is ignored, since no handler for them is actually registered in JVM 1.108 + // or via JVM_RegisterSignal. 1.109 + // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL 1.110 + return JNI_FALSE; 1.111 + } 1.112 + 1.113 + os::signal_raise(sig); 1.114 + return JNI_TRUE; 1.115 +JVM_END 1.116 + 1.117 + 1.118 +/* 1.119 + All the defined signal names for Solaris are defined by str2sig(). 1.120 + 1.121 + NOTE that not all of these names are accepted by our Java implementation 1.122 + 1.123 + Via an existing claim by the VM, sigaction restrictions, or 1.124 + the "rules of Unix" some of these names will be rejected at runtime. 1.125 + For example the VM sets up to handle USR1, sigaction returns EINVAL for 1.126 + CANCEL, and Solaris simply doesn't allow catching of KILL. 1.127 + 1.128 + Here are the names currently accepted by a user of sun.misc.Signal with 1.129 + 1.4.1 (ignoring potential interaction with use of chaining, etc): 1.130 + 1.131 + HUP, INT, TRAP, IOT, ABRT, EMT, BUS, SYS, PIPE, ALRM, TERM, USR2, 1.132 + CLD, CHLD, PWR, WINCH, URG, POLL, IO, TSTP, CONT, TTIN, TTOU, VTALRM, 1.133 + PROF, XCPU, XFSZ, FREEZE, THAW, LOST 1.134 +*/ 1.135 + 1.136 +JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name)) 1.137 + 1.138 + int sig; 1.139 + 1.140 + /* return the named signal's number */ 1.141 + 1.142 + if(str2sig(name, &sig)) 1.143 + return -1; 1.144 + else 1.145 + return sig; 1.146 + 1.147 +JVM_END 1.148 + 1.149 + 1.150 +//Reconciliation History 1.151 +// 1.4 98/10/07 13:39:41 jvm_win32.cpp 1.152 +// 1.6 99/06/22 16:39:00 jvm_win32.cpp 1.153 +//End