From: merlyn dot tgz at gmail dot com Operating system: Ubuntu PHP version: 5.3.14 Package: PCNTL related Bug Type: Bug Bug description:sleep() strange behavior on pcntl signal event
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 -- Edit bug report at https://bugs.php.net/bug.php?id=62413&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62413&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62413&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62413&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62413&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62413&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62413&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62413&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62413&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62413&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62413&r=support Expected behavior: https://bugs.php.net/fix.php?id=62413&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62413&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62413&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62413&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62413&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62413&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62413&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62413&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62413&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62413&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62413&r=mysqlcfg