Process behaviour after receiving a SIGSEGV signal? Process behaviour after receiving a SIGSEGV signal? unix unix

Process behaviour after receiving a SIGSEGV signal?


As the documentation you found says the response of the OS on returning from a SIGSEGV is undefined. Specifically for this instance it means that the relevant library standards don't define where it should resume but leave it to the exact details of the machine it's running on.

From memory X86 derived machines will restart the faulting instruction. However, Other processors skip that instruction an continue with the next. In general neither method is that useful as they both can create very weird behaviours.

As you might guess from this exactly what is done usually depends on the processor you're running on. For a particular processor the page fault response (and other faults) are all defined precisely this includes exactly what will happen if you do an 'Return' instruction on the fault stack frame.

In general, for a portable program, the only safe thing to do in a SIGSEGV handler is to exit the program. It is, however, possibly to use setjmp/longjmp if you're very, very careful about not trapping the signal during library calls or similar.