C program to change to default action inside the signal handler
#include<stdio.h>
#include<signal.h>
#include<unistd.h>
void sig_handler(int
signo)
{
if
(signo == SIGSEGV) {
printf("received
SIGSEGV\n");
signal(signo,
SIG_DFL);
/* The raise()
function sends a signal to the calling process or thread.
In a
single-threaded program it is equivalent to
kill(getpid(),
sig);
*/
raise(signo);
}
}
int main(void)
{ /*
register signal handler */
if
(signal(SIGSEGV, sig_handler) == SIG_ERR) {
printf("\ncan't
catch SIGSEGV\n");
}
while(1)
sleep(1);
return
0;
}