|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-06-25 23:06 UTC] merlyn dot tgz at gmail dot com
[2012-06-25 23:06 UTC] merlyn dot tgz at gmail dot com
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
Description: ------------ If we install any signal handler and send that signal to our script proccess while sleep() function is running script will immideatly continue running from next string after sleep() execution. For reproduce you need to open two consoles, in first of them execute the script $ php test.php in second - determine it's pid $ ps ax|grep php test.php and send signal to script proccess $ kill -s SIGHUP 12990 In provided output example i had wait while first iteration of while loop run completely, and after that have sent four times SIGHUP signal from other terminal Test script: --------------- <?php declare(ticks=1); function echo_sig($sigNum) { echo "caught sig: $sigNum\n"; } pcntl_signal(SIGHUP, 'echo_sig'); $a = 0; while ($a < 5) { $a++; $startTime = time(); sleep(10); echo "slept " . (time() - $startTime) . " seconds\n"; } Expected result: ---------------- slept 10 seconds caught sig: 1 slept 10 seconds caught sig: 1 slept 10 seconds caught sig: 1 slept 10 seconds caught sig: 1 slept 10 seconds Actual result: -------------- slept 10 seconds caught sig: 1 slept 4 seconds caught sig: 1 slept 2 seconds caught sig: 1 slept 0 seconds caught sig: 1 slept 8 seconds