信号配置 [英] Signal dispositions

查看:63
本文介绍了信号配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你有什么理由让SIGSEGV的默认处理,

SIGFPE,SIGBUS等终止程序,当这些信号可以

时程序忽略了?很多程序都会被SIGSEGV崩溃 -

如果默认是试图继续下去,他们会更加不那么好。


~Jon~

解决方案

" Leet Jon" < jo*@nospam.comschrieb im Newsbeitrag

news:sl ******************* @ nospam.com ...


什么是SIGSEGV的默认处置的原因,

SIGFPE,SIGBUS等终止程序,当这些信号可以

只是被程序忽略了?许多程序因SIGSEGV而崩溃 -

如果默认设置试图继续下去,它们将更加不那么好。



继续使用损坏的数据?不,这不是一个理智的默认。


再见,Jojo


Leet Jon< jo * @ nospam。 comwrites:

嗨什么是为具有SIGSEGV,

SIGFPE,SIGBUS等默认配置的原因而终止程序,当这些信号可以

时被程序忽略?许多程序因SIGSEGV而崩溃 -

如果默认设置试图继续下去,它们将更加不那么好。



信号的默认处理是实现定义的(C99

7.14p4),因此你可以在comp.unix中得到更好的答案。程序员比comp.lang.c中的
更好。 (我刚刚注意到了这个帖子;我已经为comp.unix.programmer设置了

后续内容。)


然而,让程序继续运行在默认情况下发生灾难性数据损坏后,默认情况下不会是一个好主意。如果

程序在无效访问存储之后立即死亡(

是所有C标准中关于SIGSEGV的说法),然后你很有可能在将代码放入
$之前诊断并纠正问题
b $ b生产。如果错误被忽略,程序很可能会继续以微妙的方式破坏您的数据;跟踪它和

如果错误发生在客户

网站上,或者甚至在重要的演示期间,那么修复它将很困难。

-

Keith Thompson(The_Other_Keith) ks***@mib.org < ; http://www.ghoti.net/~kst>

在圣地亚哥地区寻找软件开发工作。

我们必须做点什么。这是事情。因此,我们必须这样做。

- Antony Jay和Jonathan Lynn,是部长


2007年11月2日19:10,基思·汤普森写道:

然而,让程序继续进行

灾难性数据损坏故障后默认运行不会是个好主意。如果

程序在无效访问存储之后立即死亡(

是所有C标准中关于SIGSEGV的说法),然后你很有可能在将代码放入
$之前诊断并纠正问题
b $ b生产。如果错误被忽略,程序很可能会继续以微妙的方式破坏您的数据;跟踪它并且

如果错误发生在客户

站点,或者甚至在重要演示期间,修复它将会很困难。



我相信你在这一点上完全错了。通常一个SIGSEGV

将由(例如)一个糟糕的阵列访问引起 - 后果

将高度本地化,继续执行该程序将不会

导致任何重大问题。


谁希望他们的客户运行他们的程序并让它崩溃

带有段错误?这很难说是专业的。最好尝试

你最好继续进行风暴,而不是只是倾倒用户

崩溃。


我可以理解,出于调试目的,您可能希望使用

SIGSEGV等生成核心文件,但在生产代码中,默认值

应该忽略这些信号。


Hi what''s the reason for having the default disposition for SIGSEGV,
SIGFPE, SIGBUS etc to be terminating the program, when these signals can
just be ignored by the program? Many programs crash with SIGSEGV -
they''d be much less flakey if the default was to try to carry on.

~Jon~

解决方案

"Leet Jon" <jo*@nospam.comschrieb im Newsbeitrag
news:sl*******************@nospam.com...

Hi what''s the reason for having the default disposition for SIGSEGV,
SIGFPE, SIGBUS etc to be terminating the program, when these signals can
just be ignored by the program? Many programs crash with SIGSEGV -
they''d be much less flakey if the default was to try to carry on.

Carry on with corrupted data? No, that''s not a sane default.

Bye, Jojo


Leet Jon <jo*@nospam.comwrites:

Hi what''s the reason for having the default disposition for SIGSEGV,
SIGFPE, SIGBUS etc to be terminating the program, when these signals can
just be ignored by the program? Many programs crash with SIGSEGV -
they''d be much less flakey if the default was to try to carry on.

The default handling for signals is implementation-defined (C99
7.14p4), so you might get better answers in comp.unix.programmer than
here in comp.lang.c. (I just noticed the cross-post; I''ve set
followups to comp.unix.programmer.)

However, letting a program continue running by default after a
catastrophic data-corrupting failure would not be a good idea. If a
program dies immediately after "an invalid access to storage" (which
is all the C standard says about SIGSEGV), then you have a good chance
of diagnosing and correcting the problem before putting the code into
production. If the error is ignored, the program will very likely
continue to corrupt your data in subtle ways; tracking it down and
fixing it is going to be difficult if the error occurs at a customer
site, or even during an important demo.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


On 2 Nov 2007 at 19:10, Keith Thompson wrote:

However, letting a program continue running by default after a
catastrophic data-corrupting failure would not be a good idea. If a
program dies immediately after "an invalid access to storage" (which
is all the C standard says about SIGSEGV), then you have a good chance
of diagnosing and correcting the problem before putting the code into
production. If the error is ignored, the program will very likely
continue to corrupt your data in subtle ways; tracking it down and
fixing it is going to be difficult if the error occurs at a customer
site, or even during an important demo.

I believe you are completely wrong on this point. Very often a SIGSEGV
will be caused by (say) a single bad array access - the consequences
will be highly localized, and carrying on with the program will not
cause any significant problems.

Who wants their customer to run their program and have it just crash
with a segfault? That hardly comes across as professional. Better to try
your best to carry on and weather the storm than to just dump the user
with a crash.

I can understand that for debugging purposes you might want to have
SIGSEGV etc. generate a core file, but in production code the default
should be for these signals to be ignored.


这篇关于信号配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆