Which (untrapped) signals will cause a Perl program to stop executing?
What signals will cause a Perl program to stop running if their %SIG
entries are not explicitly set?开发者_如何学Go
The answer is platform dependent. To see the default behavior of each signal on your own system, download the Signals::XSIG
module (you don't need to install it) and run the program spike/analyze_default_signal_behavior.pl
(with no arguments). Or just download and run the script from here.
Note that some signals cannot be trapped by your program even if you do install a %SIG
handler. This is also system dependent but usually includes at least SIGKILL
and SIGSTOP
.
It is easier to talk about the ones that won't stop your program. On my machine (RHEL), everything but FPE (floating point exception), CHLD (child status change), CONT (continue process), URG (urgent condition on socket), and WINCH (window size change) cause the Perl program to stop executing.
Four of the signals don't cause the program to exit, but temporarily cause the program to stop execution: STOP (stop, unblockable), TSTP (terminal stop), and TTIN (Background read from tty), TTOU (Background write to tty). The program will start running again if it recieves CONT.
From man kill
on 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
精彩评论