1
|
1 |
/*
|
|
2 |
* Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include "incls/_precompiled.incl"
|
|
26 |
#include "incls/_jvm_windows.cpp.incl"
|
|
27 |
|
|
28 |
#include <signal.h>
|
|
29 |
|
|
30 |
JVM_LEAF(void*, JVM_GetThreadInterruptEvent())
|
|
31 |
return Thread::current()->osthread()->interrupt_event();
|
|
32 |
JVM_END
|
|
33 |
|
|
34 |
// sun.misc.Signal ///////////////////////////////////////////////////////////
|
|
35 |
// Signal code is mostly copied from classic vm, signals_md.c 1.4 98/08/23
|
|
36 |
/*
|
|
37 |
* This function is included primarily as a debugging aid. If Java is
|
|
38 |
* running in a console window, then pressing <CTRL-BREAK> will cause
|
|
39 |
* the current state of all active threads and monitors to be written
|
|
40 |
* to the console window.
|
|
41 |
*/
|
|
42 |
|
|
43 |
JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
|
|
44 |
// Copied from classic vm
|
|
45 |
// signals_md.c 1.4 98/08/23
|
|
46 |
void* newHandler = handler == (void *)2
|
|
47 |
? os::user_handler()
|
|
48 |
: handler;
|
|
49 |
switch (sig) {
|
|
50 |
case SIGFPE:
|
|
51 |
return (void *)-1; /* already used by VM */
|
|
52 |
case SIGBREAK:
|
|
53 |
if (!ReduceSignalUsage) return (void *)-1;
|
|
54 |
|
|
55 |
/* The following signals are used for Shutdown Hooks support. However, if
|
|
56 |
ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
|
|
57 |
System.exit(), Java is not allowed to use these signals, and the the
|
|
58 |
user is allowed to set his own _native_ handler for these signals and
|
|
59 |
invoke System.exit() as needed. Terminator.setup() is avoiding
|
|
60 |
registration of these signals when -Xrs is present. */
|
|
61 |
case SHUTDOWN1_SIGNAL:
|
|
62 |
case SHUTDOWN2_SIGNAL:
|
|
63 |
if (ReduceSignalUsage) return (void*)-1;
|
|
64 |
}
|
|
65 |
|
|
66 |
void* oldHandler = os::signal(sig, newHandler);
|
|
67 |
if (oldHandler == os::user_handler()) {
|
|
68 |
return (void *)2;
|
|
69 |
} else {
|
|
70 |
return oldHandler;
|
|
71 |
}
|
|
72 |
JVM_END
|
|
73 |
|
|
74 |
|
|
75 |
JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
|
|
76 |
if (ReduceSignalUsage) {
|
|
77 |
// do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,BREAK_SIGNAL
|
|
78 |
// to be raised when ReduceSignalUsage is set, since no handler
|
|
79 |
// for them is actually registered in JVM or via JVM_RegisterSignal.
|
|
80 |
if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
|
|
81 |
sig == SIGBREAK) {
|
|
82 |
return JNI_FALSE;
|
|
83 |
}
|
|
84 |
}
|
|
85 |
os::signal_raise(sig);
|
|
86 |
return JNI_TRUE;
|
|
87 |
JVM_END
|
|
88 |
|
|
89 |
|
|
90 |
/*
|
|
91 |
All the defined signal names for Windows.
|
|
92 |
|
|
93 |
NOTE that not all of these names are accepted by FindSignal!
|
|
94 |
|
|
95 |
For various reasons some of these may be rejected at runtime.
|
|
96 |
|
|
97 |
Here are the names currently accepted by a user of sun.misc.Signal with
|
|
98 |
1.4.1 (ignoring potential interaction with use of chaining, etc):
|
|
99 |
|
|
100 |
(LIST TBD)
|
|
101 |
|
|
102 |
*/
|
|
103 |
struct siglabel {
|
|
104 |
char *name;
|
|
105 |
int number;
|
|
106 |
};
|
|
107 |
|
|
108 |
struct siglabel siglabels[] =
|
|
109 |
/* derived from version 6.0 VC98/include/signal.h */
|
|
110 |
{"ABRT", SIGABRT, /* abnormal termination triggered by abort cl */
|
|
111 |
"FPE", SIGFPE, /* floating point exception */
|
|
112 |
"SEGV", SIGSEGV, /* segment violation */
|
|
113 |
"INT", SIGINT, /* interrupt */
|
|
114 |
"TERM", SIGTERM, /* software term signal from kill */
|
|
115 |
"BREAK", SIGBREAK, /* Ctrl-Break sequence */
|
|
116 |
"ILL", SIGILL}; /* illegal instruction */
|
|
117 |
|
|
118 |
JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
|
|
119 |
/* find and return the named signal's number */
|
|
120 |
|
|
121 |
for(int i=0;i<sizeof(siglabels)/sizeof(struct siglabel);i++)
|
|
122 |
if(!strcmp(name, siglabels[i].name))
|
|
123 |
return siglabels[i].number;
|
|
124 |
return -1;
|
|
125 |
JVM_END
|