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.