--- /dev/null
+<?php
+
+$t = 3;
+
+function busy_sleep($how_long)
+{
+ $now = time();
+
+ while($now + $how_long > time());
+}
+
--FILE--
<?php
-$t = 3;
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
set_time_limit($t);
while(1) {
echo 1;
- sleep(1);
+ busy_sleep(1);
}
?>
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function hello ($t) {
echo "call";
- sleep($t*2);
+ busy_sleep($t*2);
}
hello($t);
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f()
{
echo "call";
- sleep(4);
+ busy_sleep(4);
}
register_shutdown_function("f");
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function cb(&$i, $k, $p)
{
echo 1;
- sleep(1);
+ busy_sleep(1);
}
$a = array(1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1, 7 => 1);
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function hello ($t) {
echo "call", PHP_EOL;
- sleep($t*2);
+ busy_sleep($t*2);
}
eval('hello($t);');
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function hello ($t) {
echo "call", PHP_EOL;
- sleep($t*2);
+ busy_sleep($t*2);
}
call_user_func('hello', $t);
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f($t) {
echo "call";
- sleep($t*2);
+ busy_sleep($t*2);
throw new Exception("never reached here");
}
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f($t) {
echo "call";
- sleep($t-1);
+ busy_sleep($t-1);
throw new Exception("exception before timeout");
}
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
for($i = 0; $i < 42; $i++) {
echo 1;
- sleep(1);
+ busy_sleep(1);
}
?>
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
foreach(range(0, 42) as $i) {
echo 1;
- sleep(1);
+ busy_sleep(1);
}
?>
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f()
{
echo "call";
- sleep(4);
+ busy_sleep(4);
}
register_shutdown_function("f");