How to write a signal handler to catch SIGSEGV?

前端 未结 5 1378
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 15:26

I want to write a signal handler to catch SIGSEGV. I protect a block of memory for read or write using

char *buffer;
char *p;
char a;
int pagesize = 4096;

         


        
5条回答
  •  死守一世寂寞
    2020-11-22 15:52

    You can recover from SIGSEGV on linux. Also you can recover from segmentation faults on Windows (you'll see a structured exception instead of a signal). But the POSIX standard doesn't guarantee recovery, so your code will be very non-portable.

    Take a look at libsigsegv.

提交回复
热议问题