Quote:
Originally Posted by
sree_ec
@jim mcnamara
Thank you for the explanation.
It means the same instruction which would have caused trouble keeps on getting to the execution point and OS alerts me infinite times.
So , this would be the case for all SIGSEGV/SIGBUS cases. Then can anyone tell me what could be the best possible algorithm to handle these types of signals.
Would it be anything like
1. Check the reason for signal.
2. Alert user/ get information for debugging
2. Terminate execution from the signal handler itself.(if i return from sig handler, it means that i am eligible for another signal, isn't it?)
Regards,
Sree
On some platforms, you won't get infinite recursion: the process shall be terminated. But anyway you have to account of that possibility, as you experienced it hardly. The way I usually deal with signal caused by HW exception in signal handler is:
- log whatever I can to locate the problem post-mortem. This could be for instance the address of the IP (Instruction Pointer) that generates the exception, or better of stack frame, or even fire a debugger (if you can afford it). Make sure however to only call functions that can be safely used in signal handlers (POSIX calls them async-signal-safe).
- restore the default signal handler for the signal caught.
- return from the handler.
The return from the handler triggers again the exception, but that time the default signal handler is called, causing normally process termination (and usually, a core dump too).
HTH,
Loïc.