sigactionを定義しましたが、正常に動作します。ただし、アクションが完了した後、元の信号を復元したいと思います。これは私のシグアクションです:
static void signal_handler(int signal, siginfo_t *info, void *reserved)
{
//Some logging statements
//How do I restore the original signal here??
}
シグナルハンドラはJNI_Onloadから設定されます。
extern "C" jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
{
struct sigaction handler, action_old;
memset(&handler, 0, sizeof(handler));
handler.sa_sigaction = signal_handler;
handler.sa_flags = SA_SIGINFO;
sigaction(SIGILL, &handler, &action_old);
sigaction(SIGABRT, &handler, &action_old);
sigaction(SIGBUS, &handler, &action_old);
sigaction(SIGFPE, &handler, &action_old);
sigaction(SIGSEGV, &handler, &action_old);
sigaction(SIGSTKFLT, &handler, &action_old);
//Can I restore prior signal here???
return JNI_VERSION_1_6;
}