196 throw new IllegalArgumentException("Unhandled signal: " + sig);
197 }
198 raise0(sig.number);
199 }
200
201 /* Called by the VM to execute Java signal handlers. */
202 private static void dispatch(final int number) {
203 final Signal sig = signals.get(number);
204 final SignalHandler handler = handlers.get(sig);
205
206 Runnable runnable = new Runnable () {
207 public void run() {
208 // Don't bother to reset the priority. Signal handler will
209 // run at maximum priority inherited from the VM signal
210 // dispatch thread.
211 // Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
212 handler.handle(sig);
213 }
214 };
215 if (handler != null) {
216 new ManagedLocalsThread(runnable, sig + " handler").start();
217 }
218 }
219
220 /* Find the signal number, given a name. Returns -1 for unknown signals. */
221 private static native int findSignal(String sigName);
222 /* Registers a native signal handler, and returns the old handler.
223 * Handler values:
224 * 0 default handler
225 * 1 ignore the signal
226 * 2 call back to Signal.dispatch
227 * other arbitrary native signal handlers
228 */
229 private static native long handle0(int sig, long nativeH);
230 /* Raise a given signal number */
231 private static native void raise0(int sig);
232 }
|
196 throw new IllegalArgumentException("Unhandled signal: " + sig);
197 }
198 raise0(sig.number);
199 }
200
201 /* Called by the VM to execute Java signal handlers. */
202 private static void dispatch(final int number) {
203 final Signal sig = signals.get(number);
204 final SignalHandler handler = handlers.get(sig);
205
206 Runnable runnable = new Runnable () {
207 public void run() {
208 // Don't bother to reset the priority. Signal handler will
209 // run at maximum priority inherited from the VM signal
210 // dispatch thread.
211 // Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
212 handler.handle(sig);
213 }
214 };
215 if (handler != null) {
216 new Thread(null, runnable, sig + " handler", 0, false).start();
217 }
218 }
219
220 /* Find the signal number, given a name. Returns -1 for unknown signals. */
221 private static native int findSignal(String sigName);
222 /* Registers a native signal handler, and returns the old handler.
223 * Handler values:
224 * 0 default handler
225 * 1 ignore the signal
226 * 2 call back to Signal.dispatch
227 * other arbitrary native signal handlers
228 */
229 private static native long handle0(int sig, long nativeH);
230 /* Raise a given signal number */
231 private static native void raise0(int sig);
232 }
|