Doc #77436 [NEW]: Missing note about OS specific behavior
| From: | kbush at rvhsolutions dot com | Date: | Thu, 10 Jan 2019 00:34:05 +0000 |
| Subject: | Doc #77436 [NEW]: Missing note about OS specific behavior | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-16316@lists.php.net to get a copy of this message | ||
From: kbush at rvhsolutions dot com
Operating system: win & nix
PHP version: 7.2.13
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Missing note about OS specific behavior
Description:
------------
---
From manual page: https://php.net/function.sleep
---
The behavior of sleep differs between windows and nix OS's but this
behavior is not documented.
Specifically, sleep counts towards max_execution_time in windows but not
in nix.
Something is mentioned on the set_time_limit() page but it is not
abundantly clear that sleep() time will be ignored.
Please add a note to the sleep page indicating that the behavior differs
between operating systems. Also, it wouldn't hurt to add sleep() to the
note block on set_time_limit after the system() reference.
Attached some code if you wish to verify this behavior. In windows you
get 10 lines, in nix you get 30.
We ran into this issue after migrating some old scripts from windows to
nix and occasionally they seemed to run forever.
PS, if this could be fixed so that sleep does count toward execution
time on nix, that would be best. Because of this difference a script
with a 30 second timeout could run for months if stuck in a loop with
sleep in it. That completely invalidates the point of a max execution
time...
Test script:
---------------
<?php
set_time_limit(10); $i = 1;
while($i<=30){
echo "1 second has passed and the max_execution_time is:
".ini_get("max_execution_time")." - Run $i times so far...\r\n<br>";
sleep(1); $i++;
}
Expected result:
----------------
1 second has passed and the max_execution_time is: 10 - Run 1 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 2 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 3 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 4 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 5 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 6 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 7 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 8 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 9 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 10 times so
far...
( ! ) Fatal error: Maximum execution time of 10 seconds exceeded in
test.php on line 6
Actual result:
--------------
1 second has passed and the max_execution_time is: 10 - Run 1 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 2 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 3 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 4 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 5 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 6 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 7 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 8 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 9 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 10 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 11 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 12 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 13 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 14 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 15 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 16 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 17 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 18 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 19 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 20 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 21 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 22 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 23 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 24 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 25 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 26 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 27 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 28 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 29 times so
far...
1 second has passed and the max_execution_time is: 10 - Run 30 times so
far...
--
Edit bug report at https://bugs.php.net/bug.php?id=77436&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77436&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77436&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77436&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77436&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77436&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77436&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77436&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77436&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77436&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77436&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77436&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77436&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77436&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77436&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77436&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77436&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77436&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77436&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77436&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77436&r=mysqlcfg