为什么超时不停止无限循环
why timeout not stop infinite loop
为什么 php 或 apache 不停止无限循环?
while (true)
{
sleep(5);
}
Apache 默认 TimeOut = 300。
Php - max_execution_time = 30
但是这个循环可以工作一个小时。为什么?
由于 sleep() 发生在脚本之外,因此它不会影响脚本的最长执行时间。
Note: The set_time_limit() function and the configuration directive
max_execution_time only affect the execution time of the script
itself. Any time spent on activity that happens outside the execution
of the script such as system calls using system(), the sleep()
function, database queries, etc. is not included when determining the
maximum time that the script has been running.
http://php.net/manual/en/function.sleep.php
为什么 php 或 apache 不停止无限循环?
while (true)
{
sleep(5);
}
Apache 默认 TimeOut = 300。 Php - max_execution_time = 30
但是这个循环可以工作一个小时。为什么?
由于 sleep() 发生在脚本之外,因此它不会影响脚本的最长执行时间。
Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), the sleep() function, database queries, etc. is not included when determining the maximum time that the script has been running. http://php.net/manual/en/function.sleep.php