ccheung@5420: /* ccheung@5420: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. ccheung@5420: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ccheung@5420: * ccheung@5420: * This code is free software; you can redistribute it and/or modify it ccheung@5420: * under the terms of the GNU General Public License version 2 only, as ccheung@5420: * published by the Free Software Foundation. ccheung@5420: * ccheung@5420: * This code is distributed in the hope that it will be useful, but WITHOUT ccheung@5420: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ccheung@5420: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ccheung@5420: * version 2 for more details (a copy is included in the LICENSE file that ccheung@5420: * accompanied this code). ccheung@5420: * ccheung@5420: * You should have received a copy of the GNU General Public License version ccheung@5420: * 2 along with this work; if not, write to the Free Software Foundation, ccheung@5420: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ccheung@5420: * ccheung@5420: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ccheung@5420: * or visit www.oracle.com if you need additional information or have any ccheung@5420: * questions. ccheung@5420: */ ccheung@5420: ccheung@5420: #include ccheung@5420: #include ccheung@5420: #include ccheung@5420: #include ccheung@5420: ccheung@5420: #ifdef __cplusplus ccheung@5420: extern "C" { ccheung@5420: #endif ccheung@5420: ccheung@5420: void sig_handler(int sig, siginfo_t *info, ucontext_t *context) { ccheung@5420: ccheung@5420: printf( " HANDLER (1) " ); ccheung@5420: } ccheung@5420: ccheung@5420: JNIEXPORT void JNICALL Java_TestJNI_doSomething(JNIEnv *env, jclass klass, jint val) { ccheung@5420: struct sigaction act; ccheung@5420: struct sigaction oact; ccheung@5420: ccheung@5420: act.sa_flags = SA_ONSTACK|SA_RESTART|SA_SIGINFO; ccheung@5420: sigfillset(&act.sa_mask); ccheung@5420: act.sa_handler = SIG_DFL; ccheung@5420: act.sa_sigaction = (void (*)())sig_handler; ccheung@5420: sigaction(0x20+val, &act, &oact); ccheung@5420: ccheung@5420: printf( " doSomething(%d) " , val); ccheung@5420: printf( " old handler = %p " , oact.sa_handler); ccheung@5420: } ccheung@5420: ccheung@5420: #ifdef __cplusplus ccheung@5420: } ccheung@5420: #endif ccheung@5420: