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

问题描述

目前,我赶上SIGSEGV,自己发送一封电子邮件,然后中止(),所以我可以得到一个核心文件和调试我的程序。 (如果我没赶上,就没有办法,我不知道我的特定程序segfaulted。我的计划是从我自己的一个单独的服务器上运行。)

Currently, I catch SIGSEGV, send myself an email, and then abort() so I can get a core file and debug my program. (If I did not catch, there would be no way that I would not know that my particular program segfaulted. My program is run in a separate server from my own.)

有没有我应该捕获调试或我应该知道的?

Are there any other signals that I should catch for debugging or for reasons that I should know about ?

推荐答案

是什么让你认为一个SEGV还没有的的损坏您的程序存储器这么多,发送电子邮件,试图将不引人注目的失败?

What makes you think that a SEGV hasn't already corrupted your program memory so much that an attempt to send email won't fail spectacularly?

您应该遵循的责任实践分工和从完全的不同的的程序。

You should follow division of responsibility practices and monitor your program from a totally different program.

只要有一个(非常简单所以它不太可能会失败)计划,检查,以确保您的主要程序仍在运行,如果没有,您发送该电子邮件。你甚至可以做防御纵深和运行两个棋子,这两种检查的主要项目和对方。

Simply have a (very simple so it's far less likely to fail) program which checks to make sure your primary program is still running and, if not, send you that email. You can even do defence-in-depth and run two checkers, both of which check the primary program and each other.

如果你是偏执狂和我一样,你甚至可以在不同的机器上运行它们: - )

If you're paranoid like me, you can even run them on separate machines :-)

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

08-11 00:41