SIGSEGV的信号处理程序。 [英] Signal handler for SIGSEGV.

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

问题描述

大家好,

在我目前的项目中,我使用信号进行错误处理。由于我

无法显示完整的代码,我刚刚展示了一段重要的代码,其中

是相关的。


void sigsegenv( )

{

printf(" \ n\\\
********** FDS讯息**********) * \ n\\\
");

printf(&\\; \ n \ n ********** SEGMENTATIONFAULT
$ F $ b FDS内* ********** \ n \ n");

退出(-1);

}

int main(void)

{

............

........ ...

信号(SIGSEGV,sigsegenv);

...........

..... ......

}


我想这可能会让我们知道发生了什么。

我的信号处理程序总是没有抓住SIGSEGV。有一段时间它有时候没有捕捉到b $ b。请让我知道我做错了什么

Hi all,
In my current project I am using signals for error handling. Since I
cannot show full code, I have just shown important piece of code which
is relevant.

void sigsegenv()
{
printf("\n\n ********** F D S Message ***********\n\n");
printf("\n\n ********** S E G M E N T A T I O N F A U L T
inside F D S ***********\n\n");
exit(-1);
}
int main(void)
{
............
...........
signal ( SIGSEGV ,sigsegenv);
...........
...........
}

I think this might give some idea about what is happening.
My signal handler is not catching SIGSEGV always. Some time it is
catching sometimes not. Please let me know what am I doing wrong

推荐答案

文章< 11 *********** ***********@o13g2000cwo.googlegroups .com> ;,

< va ****** @ rediffmail.com>写道:
In article <11**********************@o13g2000cwo.googlegroups .com>,
<va******@rediffmail.com> wrote:
在我当前的项目中,我使用信号进行错误处理。由于我无法显示完整的代码,因此我刚刚展示了相关的重要代码。
void sigsegenv()
{/> printf(" \ n\\\
********** FDS讯息***********在FDS **********内打印f(&#; nn ********** SEGMENTATIONFAULT
) * \ n \ n");
退出(-1);
}
int main(无效)
{
....... ....
..........
信号(SIGSEGV,sigsegenv);
..........
... .......
}


你不能在信号处理程序中使用printf()。


在标准C中,除了调用exit,重置信号处理程序,

或一个*非常少量的其他东西,你所能做的就是设置

a sig_atomic_t的volatile变量。

我认为这可能会对发生的事情有所了解。
我的信号处理程序始终没有捕获SIGSEGV。有时它有时会捕捉到。请让我知道我做错了什么
In my current project I am using signals for error handling. Since I
cannot show full code, I have just shown important piece of code which
is relevant. void sigsegenv()
{
printf("\n\n ********** F D S Message ***********\n\n");
printf("\n\n ********** S E G M E N T A T I O N F A U L T
inside F D S ***********\n\n");
exit(-1);
} int main(void)
{
...........
..........
signal ( SIGSEGV ,sigsegenv);
..........
..........
}
You cannot use printf() inside a signal handler.

In standard C, other than calling exit, resetting the signal handler,
or a *very* small number of other things, all you can do is set
a volatile variable of sig_atomic_t .
I think this might give some idea about what is happening.
My signal handler is not catching SIGSEGV always. Some time it is
catching sometimes not. Please let me know what am I doing wrong




你有什么证据表明处理程序没有捕获SIGSEGV?

如果它只是printf()没有出现,那么你可能会遇到限制你在处理程序中可以做什么。


-

一切都是虚荣。 - 传道书



What evidence have you found that the handler is not catching SIGSEGV ?
If it is just that the printf() are not occuring, then you might
be encountering the restrictions on what you can do in a handler.

--
All is vanity. -- Ecclesiastes


Walter Roberson写道:
Walter Roberson wrote:

你不能在信号处理程序中使用printf()。

在标准C中,除了调用exit,重置信号处理程序,
或*非常少量的其他事情,你所能做的就是设置一个sig_atomic_t的易变变量。

You cannot use printf() inside a signal handler.

In standard C, other than calling exit, resetting the signal handler,
or a *very* small number of other things, all you can do is set
a volatile variable of sig_atomic_t .



您能否告诉我有关信号处理程序的限制或

我可以找到有关信号处理程序限制的更多信息?


谢谢,

Madhav。


Could you please tell me about restrictions on signal handlers or where
I can find more info about restrictions on signal handlers?

Thanks,
Madhav.


Madhav说:
Madhav said:
Walter Roberson写道:
Walter Roberson wrote:

你不能在信号处理程序中使用printf()。

在标准C中,除了调用exit,重置信号处理程序,你能告诉我吗?关于信号处理程序的限制

You cannot use printf() inside a signal handler.

In standard C, other than calling exit, resetting the signal handler,
or a *very* small number of other things, all you can do is set
a volatile variable of sig_atomic_t .
Could you please tell me about restrictions on signal handlers




他刚刚做了。

或者我可以在哪里找到有关信号处理程序限制的更多信息?



He just did.
or where I can find more info about restrictions on signal handlers?




这就是整件事。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)



That''s the whole thing.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


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

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