Results 1 to 1 of 1
Hi,
Need assistance regarding SIGSEGV signal handling.
I want the signal handler to catch the signal do some coding there, and return to main.
I succeeded in catching the signal ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-26-2008 #1Just Joined!
- Join Date
- Nov 2007
- Posts
- 10
Need help in catching and handling SIGSEGV signal
Hi,
Need assistance regarding SIGSEGV signal handling.
I want the signal handler to catch the signal do some coding there, and return to main.
I succeeded in catching the signal SIGSEGV.
But the control does not return to main from signal handler function.
Please guide me to solve this problem.
I have written a sample code to catch the SIGSEGV signal and handle it.
My Sample Code:
_______________
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
void seg()
{
printf("SEGV caught\n");
}
int main ( )
{
int* ptr = (int*)0;
signal( SIGSEGV, seg);
*ptr = 1;
printf("End of main\n");
return 0;
}
OUTPUT:
---------------
SEGV caught
SEGV caught
....
....
Goes on like this infinitely and control does not return to main.
Thanks,
Regards,
Janardhan


Reply With Quote
