Is it possible to prevent zend engine to free resources allocated in PHP?
For example, when a process 开发者_开发技巧is forked() and the resource is duplicated to the child process, when either child process or parent process exit, the resource is free thus other processes can't access them any more.
Freeing resourses is not the problem, because the parent and child have no access to each other's resourses. Maybe you are talking about mysql connection. The problem is that even if you don't call mysql_close()
it's called by php. This is an example
mysql_connect(...);
if(pcntl_fork()) exit();
mysql_query( ... ); //no mysql connection here
I heard that parent can prevent this by killing itself with SIGKILL
, but I haven't tested it. Should be something like:
mysql_connect(...);
if(pcntl_fork()) {
posix_kill ( posix_getpid() , SIGKILL);
exit(); // won't hurt to leave it here
}
mysql_query( ... ); //no mysql connection here
Or if parent starts many children and they close connection to database on quit you can use the same approach on children.
精彩评论