apache_child_terminate

(PHP 4 >= 4.0.5, PHP 5)

apache_child_terminate -- 在本次请求结束后终止 apache 进程

说明

bool apache_child_terminate ( void )

apache_child_terminate() 将把运行当前 PHP 请求的 Apache 进程注册为终止状态,一旦结束 PHP 代码的运行此进程将终止。可以用在占用大量内存的脚本后面来终止该进程,因为通常内存只在内部释放而不会还给操作系统。

返回值

如果 PHP 以 Apache 1 模块方式运行,且 Apache 的版本是非多线程的,以及激活了 PHP 指令 child_terminate,则返回 TRUE。如果不满足上述条件则返回 FALSE 并生成一条 E_WARNING 级的错误信息。

注释

注: 本函数未在 Windows 平台下实现。

参见

exit()


add a note add a note User Contributed Notes
sam at liddicott dot com
14-Mar-2006 12:26
apache_child_terminate does NOT terminate the running script.

It terminates the apache process running the script AFTER it has finished running the script.

It has no side effects on page generation, you should only call it in cases where you know your script will have used a lot of memory and you want to give it back to the system.
daniele_dll at yahoo dot it
07-Jul-2005 04:29
Don't use this function to simply terminate your scripts!

Using this function you will cause a BIG overhead to apache, infact it will terminate and restart child processes instead to execute more requests in the same process!

Use die or exit instead
anonymous at person dot com
28-Nov-2003 07:14
<?php
function term() {
 if(
function_exists('apache_child_terminate')) {
 
apache_child_terminate();
 }
die(
'Terminated');
}
?>

Also, when apache_child_terminate is called, it terminates the script, so die()/exit() is not necessary if the script is 100% sure to be on an apache 1.x server, else a die()/exit() is as good as it gets.

I found its a semi-good idea to terminate the child if available after critical low-level errors.