我正在查看这个 PHP 代码来执行信号陷阱:
<?php
/*
SIGTERM for 'kill' default of -15
SIGINT for control-c
*/
declare(ticks = 1);
pcntl_signal(SIGTERM, "signal_handler");
pcntl_signal(SIGINT, "signal_handler");
function signal_handler($signal) {
switch($signal) {
case SIGTERM:
print "Caught SIGTERM\n";
exit;
case SIGKILL:
print "Caught SIGKILL\n";
exit;
case SIGINT:
print "Caught SIGINT\n";
exit;
}
}
while(1) {
//
}
?>
SIGKILL 是否可以等同于“kill”命令的数字选项,例如“kill -9”?如果不是,什么条件会导致 SIGKILL 信号?谢谢!