2011-06-13 30 views
1

如果Perl程序的%SIG条目未明确设置,哪些信号将导致Perl程序停止运行?哪些(未经处理的)信号会导致Perl程序停止执行?

+1

在哪个平台上(S)? – 2011-06-13 17:37:48

+0

问题是跨平台,我的答案下面是平台特定的(因为这是我可以轻松访问)。看起来好像答案与SIG_DFL被定义为什么有很大关系。异常似乎是FPE,它看起来像默认设置为SIG_IGN。 – 2011-06-13 17:58:10

回答

5

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

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

2

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

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

1

man kill Debian的,

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