Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

pcntl_fork php mysql "MySQL server has gone away"

                        $model_mod = new Model_Base();
                        $model_mod->disconnect();
                        $pid = pcntl_fork();
                        //Both the parent process and the child process will execute the following code
                        if ($pid == -1) {
                            //Error handling: return -1 when failed to create a child process.
                            die('could not fork');
                        } else if ($pid) {
                            $model_mod->connect();
             
                            //The parent process will get the child process number, so here is the logic executed by the parent process
                            pcntl_wait($status); //Wait for the interruption of the child process to prevent the child process from becoming a zombie process.
                        } else {
                            
                            //The $pid obtained by the child process is 0, so here is the logic executed by the child process.
                        }
Source by www.programmerall.com #
 
PREVIOUS NEXT
Tagged: #php #mysql #server
ADD COMMENT
Topic
Name
2+4 =