S
subramanian
Consider the following code: segment violation is deliberately
generated to catch the SIGSEGV signal. The handler for this signal,
namely SIGSEGV_handler, is called. However after the handler is
finished, control does not return to the printf statement in main()
which is present after the strcpy statement. Instead Segmentation
violation error message is printed in Redhat Linux and the program is
aborted. In VC++, the SIGSEGV_handler is called and then the program
crashes. Is this the expected behaviour ?
void SIGSEGV_handler(int num);
int main(void)
{
char *str = NULL;
signal(SIGSEGV, SIGSEGV_handler);
strcpy(str, "TEST");
printf("After signal handling\n");
return 0;
}
void SIGSEGV_handler(int num)
{
printf("SIGSEGV_handler called with the argument %d\n", num);
return;
}
generated to catch the SIGSEGV signal. The handler for this signal,
namely SIGSEGV_handler, is called. However after the handler is
finished, control does not return to the printf statement in main()
which is present after the strcpy statement. Instead Segmentation
violation error message is printed in Redhat Linux and the program is
aborted. In VC++, the SIGSEGV_handler is called and then the program
crashes. Is this the expected behaviour ?
void SIGSEGV_handler(int num);
int main(void)
{
char *str = NULL;
signal(SIGSEGV, SIGSEGV_handler);
strcpy(str, "TEST");
printf("After signal handling\n");
return 0;
}
void SIGSEGV_handler(int num)
{
printf("SIGSEGV_handler called with the argument %d\n", num);
return;
}