linux SIGFPE信号处理的疑惑
来源:互联网 发布:图案设计软件 编辑:程序博客网 时间:2024/06/06 05:05
发现一个关于信号的问题:SIGFPE是浮点运算异常,我写了这么一段程序:
void sig_deal(int signo)
{
printf("deal %d\n", signo);
}
int main(int argc, char * argv[])
{
signal(SIGFPE, sig_deal);
printf("%d",1/0);
exit(1);
}
sig_deal函数是不是应该只被调用一次,可我的运行结果却是:
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
**********
void sig_deal(int signo)
{
printf("deal %d\n", signo);
}
int main(int argc, char * argv[])
{
signal(SIGFPE, sig_deal);
printf("%d",1/0);
exit(1);
}
sig_deal函数是不是应该只被调用一次,可我的运行结果却是:
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
deal 8
**********
为什么不是执行一次,而是执行很多次系统调用??
看手册发现这么一段话:
According to POSIX, the behavior of a process is undefined after it ignores a SIGFPE, SIGILL, or SIGSEGV
signal that was not generated by kill(2) or raise(3). Integer division by zero has undefined result.
On some architectures it will generate a SIGFPE signal. (Also dividing the most negative integer by -1
may generate SIGFPE.) Ignoring this signal might lead to an endless loop.
signal that was not generated by kill(2) or raise(3). Integer division by zero has undefined result.
On some architectures it will generate a SIGFPE signal. (Also dividing the most negative integer by -1
may generate SIGFPE.) Ignoring this signal might lead to an endless loop.
看样子是说SIGFPE信号对于进程的影响是不确定的。
0 0
- linux SIGFPE信号处理的疑惑
- Linux C 异常处理:信号机制 SIGFPE/signal()/raise()
- 除零异常信号 SIGFPE
- Linux的信号处理
- linux 信号的处理
- Linux的信号处理
- Linux的信号处理
- Linux的信号处理
- linux 信号&信号处理
- linux 信号&信号处理
- linux 信号&信号处理
- linux下的信号处理
- linux 信号处理 的学习
- linux下的信号处理
- Linux信号与信号处理
- Linux信号和信号处理
- linux信号处理 信号 定时器
- Linux信号与信号处理
- WINCE 禁止MFC程序窗口上的OK按钮
- vim学习心得
- 九度OJ 1372 最大子向量和(连续子数组的最大和)
- java学习记录(二)字符串
- 九度1510(字符串)
- linux SIGFPE信号处理的疑惑
- 想和你去吹吹风(张学友演唱歌曲)
- hdu 3199 动态规划
- 筛法求素数
- java学习记录(三)集合
- 求连续子数组的最大和
- PHP函数 mysql_connect()连接MySQL数据库错误的解决办法
- isMemberOfClass 和 isKindOfClass
- sql cross join