Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/solaris/vm/jvm_solaris.cpp
32285 views
/*1* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "prims/jvm.h"26#include "runtime/interfaceSupport.hpp"27#include "runtime/osThread.hpp"2829#include <signal.h>3031// sun.misc.Signal ///////////////////////////////////////////////////////////32// Signal code is mostly copied from classic vm, signals_md.c 1.4 98/08/2333/*34* This function is included primarily as a debugging aid. If Java is35* running in a console window, then pressing <CTRL-\\> will cause36* the current state of all active threads and monitors to be written37* to the console window.38*/3940JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))41// Copied from classic vm42// signals_md.c 1.4 98/08/2343void* newHandler = handler == (void *)244? os::user_handler()45: handler;46switch (sig) {47/* The following are already used by the VM. */48case SIGFPE:49case SIGILL:50case SIGSEGV:5152/* The following signal is used by the VM to dump thread stacks unless53ReduceSignalUsage is set, in which case the user is allowed to set54his own _native_ handler for this signal; thus, in either case,55we do not allow JVM_RegisterSignal to change the handler. */56case BREAK_SIGNAL:57return (void *)-1;5859/* The following signals are used for Shutdown Hooks support. However, if60ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via61System.exit(), Java is not allowed to use these signals, and the the62user is allowed to set his own _native_ handler for these signals and63invoke System.exit() as needed. Terminator.setup() is avoiding64registration of these signals when -Xrs is present.65- If the HUP signal is ignored (from the nohup) command, then Java66is not allowed to use this signal.67*/68case SHUTDOWN1_SIGNAL:69case SHUTDOWN2_SIGNAL:70case SHUTDOWN3_SIGNAL:71if (ReduceSignalUsage) return (void*)-1;72if (os::Solaris::is_sig_ignored(sig)) return (void*)1;73}7475/* Check parameterized signals. Don't allow sharing of our interrupt signal */76if (sig == os::Solaris::SIGinterrupt()) {77return (void *)-1;78}7980void* oldHandler = os::signal(sig, newHandler);81if (oldHandler == os::user_handler()) {82return (void *)2;83} else {84return oldHandler;85}86JVM_END878889JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))90if (ReduceSignalUsage) {91// do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,92// BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since93// no handler for them is actually registered in JVM or via94// JVM_RegisterSignal.95if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||96sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {97return JNI_FALSE;98}99}100else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||101sig == SHUTDOWN3_SIGNAL) && os::Solaris::is_sig_ignored(sig)) {102// do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL103// is ignored, since no handler for them is actually registered in JVM104// or via JVM_RegisterSignal.105// This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL106return JNI_FALSE;107}108109os::signal_raise(sig);110return JNI_TRUE;111JVM_END112113114/*115All the defined signal names for Solaris are defined by str2sig().116117NOTE that not all of these names are accepted by our Java implementation118119Via an existing claim by the VM, sigaction restrictions, or120the "rules of Unix" some of these names will be rejected at runtime.121For example the VM sets up to handle USR1, sigaction returns EINVAL for122CANCEL, and Solaris simply doesn't allow catching of KILL.123124Here are the names currently accepted by a user of sun.misc.Signal with1251.4.1 (ignoring potential interaction with use of chaining, etc):126127HUP, INT, TRAP, IOT, ABRT, EMT, BUS, SYS, PIPE, ALRM, TERM, USR2,128CLD, CHLD, PWR, WINCH, URG, POLL, IO, TSTP, CONT, TTIN, TTOU, VTALRM,129PROF, XCPU, XFSZ, FREEZE, THAW, LOST130*/131132JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))133134int sig;135136/* return the named signal's number */137138if(str2sig(name, &sig))139return -1;140else141return sig;142143JVM_END144145146//Reconciliation History147// 1.4 98/10/07 13:39:41 jvm_win32.cpp148// 1.6 99/06/22 16:39:00 jvm_win32.cpp149//End150151152