Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/windows/vm/jvm_windows.cpp
32284 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>3031JVM_LEAF(void*, JVM_GetThreadInterruptEvent())32return Thread::current()->osthread()->interrupt_event();33JVM_END3435// sun.misc.Signal ///////////////////////////////////////////////////////////36// Signal code is mostly copied from classic vm, signals_md.c 1.4 98/08/2337/*38* This function is included primarily as a debugging aid. If Java is39* running in a console window, then pressing <CTRL-BREAK> will cause40* the current state of all active threads and monitors to be written41* to the console window.42*/4344JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))45// Copied from classic vm46// signals_md.c 1.4 98/08/2347void* newHandler = handler == (void *)248? os::user_handler()49: handler;50switch (sig) {51case SIGFPE:52return (void *)-1; /* already used by VM */53case SIGBREAK:54if (!ReduceSignalUsage) return (void *)-1;5556/* The following signals are used for Shutdown Hooks support. However, if57ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via58System.exit(), Java is not allowed to use these signals, and the the59user is allowed to set his own _native_ handler for these signals and60invoke System.exit() as needed. Terminator.setup() is avoiding61registration of these signals when -Xrs is present. */62case SHUTDOWN1_SIGNAL:63case SHUTDOWN2_SIGNAL:64if (ReduceSignalUsage) return (void*)-1;65}6667void* oldHandler = os::signal(sig, newHandler);68if (oldHandler == os::user_handler()) {69return (void *)2;70} else {71return oldHandler;72}73JVM_END747576JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))77if (ReduceSignalUsage) {78// do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,BREAK_SIGNAL79// to be raised when ReduceSignalUsage is set, since no handler80// for them is actually registered in JVM or via JVM_RegisterSignal.81if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||82sig == SIGBREAK) {83return JNI_FALSE;84}85}86os::signal_raise(sig);87return JNI_TRUE;88JVM_END899091/*92All the defined signal names for Windows.9394NOTE that not all of these names are accepted by FindSignal!9596For various reasons some of these may be rejected at runtime.9798Here are the names currently accepted by a user of sun.misc.Signal with991.4.1 (ignoring potential interaction with use of chaining, etc):100101(LIST TBD)102103*/104struct siglabel {105char *name;106int number;107};108109struct siglabel siglabels[] =110/* derived from version 6.0 VC98/include/signal.h */111{"ABRT", SIGABRT, /* abnormal termination triggered by abort cl */112"FPE", SIGFPE, /* floating point exception */113"SEGV", SIGSEGV, /* segment violation */114"INT", SIGINT, /* interrupt */115"TERM", SIGTERM, /* software term signal from kill */116"BREAK", SIGBREAK, /* Ctrl-Break sequence */117"ILL", SIGILL}; /* illegal instruction */118119JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))120/* find and return the named signal's number */121122for(int i=0;i<sizeof(siglabels)/sizeof(struct siglabel);i++)123if(!strcmp(name, siglabels[i].name))124return siglabels[i].number;125return -1;126JVM_END127128129