this code will add apache_child_terminate() function if it is not already present.
if (!function_exists("apache_child_terminate")){
function apache_child_terminate(){
register_shutdown_function("killonexit");
}
function killonexit(){
@exec("kill ".getmypid());
}
}