哪些(未捕获的)信号会导致Perl程序停止执行?

时间:2011-06-13 17:33:28

标签: perl signals

如果未明确设置%SIG条目,哪些信号会导致Perl程序停止运行?

3 个答案:

答案 0 :(得分:5)

答案取决于平台。要查看您自己系统上每个信号的默认行为,请下载Signals::XSIG模块(您不需要安装它)并运行程序spike/analyze_default_signal_behavior.pl(不带参数)。或者只需从here下载并运行脚本。

请注意,即使您安装了%SIG处理程序,某些信号也无法被您的程序捕获。这也取决于系统,但通常至少包括SIGKILLSIGSTOP

答案 1 :(得分:2)

更容易谈论不会阻止你的程序的那些。在我的机器(RHEL)上,除了FPE(浮点异常),CHLD(子状态更改),CONT(继续进程),URG(套接字上的紧急情况)和WINCH(窗口大小更改)之外的所有内容都会导致Perl程序停止执行。

其中四个信号不会导致程序退出,但暂时导致程序停止执行:STOP(停止,不可阻塞),TSTP(终端停止)和TTIN(从tty读取背景),TTOU(背景)写给tty)。如果程序收到CONT,程序将再次开始运行。

答案 2 :(得分:1)

来自Debian的man kill

   Name     Num   Action    Description
   0          0   n/a       exit code indicates if a signal may be sent
   ALRM      14   exit
   HUP        1   exit
   INT        2   exit
   KILL       9   exit      cannot be blocked
   PIPE      13   exit
   POLL           exit
   PROF           exit
   TERM      15   exit
   USR1           exit
   USR2           exit
   VTALRM         exit
   STKFLT         exit      might not be implemented
   PWR            ignore    might exit on some systems
   WINCH          ignore
   CHLD           ignore
   URG            ignore
   TSTP           stop      might interact with the shell
   TTIN           stop      might interact with the shell
   TTOU           stop      might interact with the shell
   STOP           stop      cannot be blocked
   CONT           restart   continue if stopped, otherwise ignore
   ABRT       6   core
   FPE        8   core
   ILL        4   core
   QUIT       3   core
   SEGV      11   core
   TRAP       5   core
   SYS            core      might not be implemented
   EMT            core      might not be implemented
   BUS            core      core dump might fail
   XCPU           core      core dump might fail
   XFSZ           core      core dump might fail