强制应用程序进行核心转储和退出的正确方法是什么? [英] What is the correct way to force an app to core dump and quit?

查看:142
本文介绍了强制应用程序进行核心转储和退出的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚遇到一些使用kill系统调用向应用程序发送SIGSEGV信号的代码。这背后的理由是,这将强制应用程序核心转储和退出。

I just came across some code which used the kill system call to send a SIGSEGV signal to an app. The rationale behind this was that this would force the app to core dump and quit. This seems so wrong to me, is this normal practice?

推荐答案

SIGQUIT是发送给程序的正确信号,如果你愿意的话以产生核心转储。 kill 是正确的命令行程序发送信号(当然命名不当,因为并不是所有的信号都会杀死程序)。

SIGQUIT is the correct signal to send to a program if you wish to produce a core dump. kill is the correct command line program to send signals (it is of course poorly named, since not all signals will kill the program).

注意,你不应该发送随机信号到程序,不是所有的都会产生一个核心转储。其中许多将由程序本身处理,要么被消耗,要么被忽略,或引起其他处理。因此发送SIGSEGV是错误的。

Note, you should not send random signals to the program, not all of them will produce a core dump. Many of them will be handled by the program itself, either consumed, ignored, or induce other processing. Thus sending a SIGSEGV is wrong.

GCC说:
http://www.gnu.org/s/libc/manual/html_node/Termination-Signals.html

POSIX / Unix说:
http ://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html

POSIX/Unix Says: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html

这篇关于强制应用程序进行核心转储和退出的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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