To begin with I will point out the operating system here is RTEMS, it is an Open source RTOS and the source can be found here:
I have a pretty simple program that sets up a signal handler for SIGSEGV (which i believe is supported) using sigaction call from the documentation here:
http://docs.rtems.org/releases/rtemsdocs-4.9.2/share/rtems/html/posix_users/posix_users00033.html
My program essentially boils down to this:
void HandleAndPrintSignal()
{
printf("I am in the segfault signal handler AND I WILL HANDLE YOUR SIG!!!!\n");
exit(1);
}
void *POSIX_Init(void *args)
{
printf("BENS BIG NOTE: Initializing Signal Handler\n");
struct sigaction sa;
sa.sa_handler = HandleAndPrintSignal;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
if (sigaction (SIGSEGV, &sa, 0)) {
printf("A ERROR OCCURED WITH THIS!");
exit(1);
}
int *p = NULL;
*(p--) = 5; // Causes segfault
}
However, the problem is that when i cause a segfault in my program, the signal handler is not called but instead a kernel process is called in vectors_init.c
(RTEMS source) to print a stack trace. Is there something special that I need to do to get SIGSEGV signal in my rtems program?