Path: blob/master/src/hotspot/os/windows/jvm_windows.cpp
40931 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 "jvm.h"26#include "runtime/interfaceSupport.inline.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_END8990919293