// Корректная обработка прерывания Ctrl+C $myPid = posix_getpid(); declare(ticks = 1); function sig_handler($signo) { global $myPid; echo "TERMINATED: #".$myPid."n"; switch ($signo) { case SIGTERM: case SIGKILL: case SIGINT: case SIGHUP: die; } } pcntl_signal(SIGTERM, "sig_handler"); pcntl_signal(SIGHUP, "sig_handler"); pcntl_signal(SIGINT, "sig_handler"); echo 'start...'; sleep(4); echo "endn";
PHP Справочник v0.05 © 2007-2024 Igor Salnikov aka SunDoctor