Coming back to life after Segmentation Violation

前端 未结 13 2123
暗喜
暗喜 2020-12-08 11:26

Is it possible to restore the normal execution flow of a C program, after the Segmentation Fault error?

struct A {
    int x;
};
A* a = 0;

a->x = 123; /         


        
13条回答
  •  时光说笑
    2020-12-08 12:22

    In POSIX, your process will get sent SIGSEGV when you do that. The default handler just crashes your program. You can add your own handler using the signal() call. You can implement whatever behaviour you like by handling the signal yourself.

提交回复
热议问题