|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patcheseeiofvbw (last revision 2017-01-16 16:02 UTC by sample at email dot tst)Pull Requests |
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 08:00:01 2025 UTC |
Description: ------------ I set request_terminate_timeout to 10s in php-fpm.conf, add register a shutdown callback function in my code, but when the script execute timeout, the shutdown callback function has not been trigger. Then , I use pcntl_signal to register a signal , like: ``` pcntl_signal(SIGHUP, [$this, 'signal']); pcntl_signal(SIGTERM, [$this, 'signal']); pcntl_signal(SIGQUIT, [$this, 'signal']); pcntl_signal(SIGTSTP, [$this, 'signal']); pcntl_signal(SIGINT, [$this, 'signal']); ``` ``` public function signal($signal) { file_put_contents('/tmp/xxx.log', time(), FILE_APPEND); switch ($signal) { case SIGTERM: case SIGQUIT: case SIGINT: case SIGTSTP: exit; break; } } ``` the function signal not been trigger also. but when register shutdown function and pcntl signal exist at the same time. the register shutdown callback work, if comment out the pcntl signal, the register shutdown callback not work. why? Test script: --------------- <?php register_shutdown_callback(function(){ file_put_contents('/tmp/eee.log', time(), FILE_APPEND); }); pcntl_signal(SIGHUP, 'signal'); pcntl_signal(SIGTERM, 'signal'); pcntl_signal(SIGQUIT, 'signal'); pcntl_signal(SIGTSTP, 'signal'); pcntl_signal(SIGINT, 'signal'); function signal($signal) { file_put_contents('/tmp/xxx.log', time(), FILE_APPEND); switch ($signal) { case SIGTERM: case SIGQUIT: case SIGINT: case SIGTSTP: exit; break; } } sleep(20); echo "end"; Expected result: ---------------- pcntl signal or register shutdown callback can catch request terminate timeout correctly