其中"致命的"信号应用户级程序赶上? [英] Which "fatal" signals should a user-level program catch?

查看:109
本文介绍了其中"致命的"信号应用户级程序赶上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我知道有过去是一个类似的问题在这里

First of all, I do know that there was a similar question here in the past.

但这个问题没有正确答案。相反,它转入建议做赶上信号是什么。

But that question wasn't answered properly. Instead, it diverted into suggestion what to do to catch signals.

所以,我只想澄清:我做任何需要做的事情来处理信号。
我有分叉,通过管道监控主进程守护的应用程序。
如果主进程崩溃(例如分段故障),它具有写入所有需要的信息管道和中止信号处理程序。

So just to clarify: I've done whatever needs to be done to handle signals. I have an application that forks a daemon that monitors the main process through pipe. If a main process crashes (e.g. segmentation fault), it has a signal handler that writes all the required info to pipe and aborts.

我们的目标是让尽可能多的信息尽可能的当坏事发生应用程序的,W / O与正常的操作,如SIGHUP,SIGUSR1等搞乱。

The goal is to have as much info as possible when something bad happens to the application, w/o messing with "normal" operation, such as SIGHUP, SIGUSR1, etc.

所以我的问题是:哪些信号,我应该追上
我的意思是信号W / O我赶上他们会导致应用程序反正中止。

So my question is: which signals should I catch? I mean signals that w/o me catching them would cause application to abort anyway.

到目前为止,我想出了以下列表:

So far I've come up with the following list:


  • SIGINT(^ C,用户发起的,但还是不错的就知道了)

  • SIGTERM(杀< PID> 从壳或,据我所知,可能是内存不足的结果)

  • SIGSEGV

  • SIGILL

  • SIGFPE

  • SIGBUS

  • SIGQUIT

  • SIGINT (^C, user-initiated, but still good to know)
  • SIGTERM (kill <pid> from shell or, AFAIK, can be result of OutOfMemory)
  • SIGSEGV
  • SIGILL
  • SIGFPE
  • SIGBUS
  • SIGQUIT

有谁知道,如果我错过了什么? 杀-l 有很多人...:)

Does anybody know if I miss something? kill -l has lots of them... :)

推荐答案

我看我的高级编程UNIX环境(史蒂文斯)的复印件。根据对信号部分的表格,下面的POSIX信号将在默认情况下终止进程,如果你不抓住他们。它不会是不合理的监控所有这些,你不使用:

I'm looking at my copy of advanced programming the unix environment (Stevens). According to the table in the section on signals, the following POSIX signals will by default terminate the process, if you don't catch them. It wouldn't be unreasonable to monitor all of these that you don't use:


  • SIGABRT

  • SIGALRM

  • SIGFPE

  • SIGHUP

  • SIGILL

  • SIGINT

  • SIGKILL

  • SIGPIPE

  • SIGQUIT

  • SIGSEGV

  • SIGTERM

  • SIGUSR1

  • SIGUSR2

您可以捕捉所有这些,除了SIGKILL,但希望SIGKILL不会拿出很多时候你。

You can catch all of these except SIGKILL, but hopefully SIGKILL won't come up very often for you.

请注意,你的信号手册(人7信号)应该给你为你的系统正确的名单 - 这是POSIX列表,并且可以根据您的体系结构有所不同

Note that your signal man page (man 7 signal) should give you the proper list for your system - this is the POSIX list, and may differ depending on your architecture.

这篇关于其中&QUOT;致命的&QUOT;信号应用户级程序赶上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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