# Some strange bug

- Thread: https://externals.io/message/86593
- Original archive: https://news-web.php.net/php.internals/86593
- Started by Andrew Kluev on 2015-06-11T11:25:01+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #86593 — Andrew Kluev — 2015-06-11T11:25:01+00:00

URL: https://externals.io/message/86593#86593

I have code:

-------------------------------------
echo 'php_sapi_name: '.php_sapi_name().PHP_EOL;
echo 'max_input_time: '.ini_get('max_input_time').PHP_EOL;
echo 'max_execution_time: '.ini_get('max_execution_time').PHP_EOL;

set_time_limit(2);

echo 'max_input_time: '.ini_get('max_input_time').PHP_EOL;
echo 'max_execution_time: '.ini_get('max_execution_time').PHP_EOL;

sleep(3);

echo 'how it works?'.PHP_EOL;
-------------------------------------

And it's output
-------------------------------------------------
php_sapi_name: cli
max_input_time: -1
max_execution_time: 0
max_input_time: -1
max_execution_time: 2
how it works?
-------------------------------------------------
or
-------------------------------------------------
php_sapi_name: fpm-fcgimax_input_time: 60max_execution_time: 30max_input_time:
60max_execution_time: 2how it works?
-------------------------------------------------

I have no idea why this is happening. On Windows PHP 5.4.13 (cli)(built:
Mar 15 2013 02:07:14) it writes (Maximum execution time of 2 seconds
exceeded....)

Some info about my pc:
php -v:
PHP 5.6.7-1 (cli) (built: Mar 24 2015 12:30:15)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend
Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

uname -a:
Linux andrew-deb 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt9-2 (2015-04-13)
x86_64 GNU/Linux

php -i:
http://pastebin.com/vzeHZJn1


This is a bug or something I do not know about php?

---

## #86594 — johannes@schlueters.de — 2015-06-11T11:42:37+00:00

URL: https://externals.io/message/86593#86594 · In reply to: #86593

> sleep(3);
[...]
> This is a bug or something I do not know about php?

Max execution time is working a bit dependent on the operating system.
On Windows it is using the elapsed time ("wall clock time") on Linux
systems the CPU time. Thus on windows the sleep counts whereas on Linux
no time is spent during `sleep()`. The same difference happens when other
processes are on CPU and your PHP script was taken off CPU for other
reasons.

For details see MSDN on CreateTimerQueueTimer for Windows and the
setitimer man page with (ITIMER_PROF option) for Linux/Unix for a start.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485%
28v=vs.85%29.aspx
http://linux.die.net/man/2/setitimer


johannes

---

## #86595 — Andrew Kluev — 2015-06-11T11:58:56+00:00

URL: https://externals.io/message/86593#86595

It is very informative, but not resolve the problem, php completely ignored
my max_execution_teme setup with any SAPI, in all cases

2015-06-11 14:57 GMT+03:00 Andrew Kluev <kluev.andrew@gmail.com>:

> And php7 not working too.....
>
> php7 -v
> PHP 7.0.0-dev (cli) (built: Mar 30 2015 12:26:36) (DEBUG)
> Copyright (c) 1997-2015 The PHP Group
> Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
>
> 2015-06-11 14:55 GMT+03:00 Andrew Kluev <kluev.andrew@gmail.com>:
>
> > […]

---

## #86597 — Christoph Becker — 2015-06-11T12:09:00+00:00

URL: https://externals.io/message/86593#86597 · In reply to: #86595

Andrew Kluev wrote:

> It is very informative, but not resolve the problem, php completely ignored
> my max_execution_teme setup with any SAPI, in all cases

As Johannes wrote:

> [...] whereas on Linux no time is spent during `sleep()`.

-- 
Christoph M. Becker

---

## #86599 — Andrew Kluev — 2015-06-11T12:27:29+00:00

URL: https://externals.io/message/86593#86599

Wow! Now I understand. Thank you for the explanation

2015-06-11 15:10 GMT+03:00 Johannes Schlüter <johannes@schlueters.de>:

> As said: It looks at CPU time. sleep doesn't require CPU time. Try with
> something like while(true){} which keeps PHP on CPU
>
>
> $ cat test.php
> <?php
> echo 'php_sapi_name: '.php_sapi_name().PHP_EOL;
> echo 'max_input_time: '.ini_get('max_input_time').PHP_EOL;
> echo 'max_execution_time: '.ini_get('max_execution_time').PHP_EOL;
>
> set_time_limit(2);
>
> echo 'max_input_time: '.ini_get('max_input_time').PHP_EOL;
> echo 'max_execution_time: '.ini_get('max_execution_time').PHP_EOL;
>
> while (true) {}
>
> echo 'how it works?'.PHP_EOL;
>
> $ ./sapi/cli/php -v
> PHP 7.0.0-dev (cli) (built: Jun 11 2015 14:04:07) (DEBUG)
> Copyright (c) 1997-2015 The PHP Group
> Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
>
> $ time ./sapi/cli/php test.php
> php_sapi_name: cli
> max_input_time: -1
> max_execution_time: 0
> max_input_time: -1
> max_execution_time: 2
>
> Fatal error: Maximum execution time of 2 seconds exceeded in test.php on
> line 11
>
> real    0m2.062s
> user    0m2.005s
> sys     0m0.016s
>
>
> 
> > […]
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485%
> > […]
