123 {
124 struct sigaction sig_action, old_sig_action;
125 sig_action.sa_sigaction = segv_handler;
126 sigemptyset(&sig_action.sa_mask);
127 sig_action.sa_flags = SA_SIGINFO | SA_NODEFER;
128 sigaction(SIGSEGV, &sig_action, &old_sig_action);
129 if(old_sig_action.sa_flags & SA_SIGINFO)
130 chained_handler = old_sig_action.sa_sigaction;
131 else if(old_sig_action.sa_handler != SIG_IGN && old_sig_action.sa_handler != SIG_DFL)
132 chained_handler = (void (*)(int,siginfo_t*,void*))old_sig_action.sa_handler;
133 }