Wow! Now I understand. Thank you for the explanation

2015-06-11 15:10 GMT+03:00 Johannes Schlüter <johan...@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
>
>
> On Thu, 2015-06-11 at 14:55 +0300, 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
> >
> >
> > 2015-06-11 14:42 GMT+03:00 Johannes Schlüter <johan...@schlueters.de>:
> >         On Thu, 2015-06-11 at 14:25 +0300, Andrew Kluev wrote:
> >         > 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
> >
> >
> >
>
>
>

Reply via email to