捕捉段错误信号信号处理程序
睿丰德科技 专注RFID识别技术和条码识别技术与管理软件的集成项目。质量追溯系统、MES系统、金蝶与条码系统对接、用友与条码系统对接
#include<signal.h>
#include<stdlib.h>
void handler(int s)
{
if(s == SIGINT) printf("now got a interrupt signal ");
if(s == SIGSEGV) printf("now got a segmentation violation signal ");
if(s == SIGILL) printf("now got an illegal instruction signal ");
exit(1);
}
int main()
{
int *p = NULL;
signal(SIGINT, handler);
signal(SIGSEGV,handler);
signal(SIGILL, handler);
*p = 0;
return 0;
}
//简单的捕捉段错误信号信号处理程序,通过signal来捕捉错误.
#include<stdio.h>
#include<signal.h>
#include<stdlib.h>
void handler(int s)
{
if(s == SIGINT) printf("now got a interrupt signal ");
if(s == SIGSEGV) printf("now got a segmentation violation signal ");
if(s == SIGILL) printf("now got an illegal instruction signal ");
exit(1);
}
int main()
{
int *p = NULL;
signal(SIGINT, handler);
signal(SIGSEGV,handler);
signal(SIGILL, handler);
*p = 0;
return 0;
}
RFID管理系统集成商 RFID中间件 条码系统中间层 物联网软件集成