Hi. I have a found a very strange and big "concurrence" problem after develop a CLI tool which parallelizes data processing by using "pcntrl_fork", ( If we run the same executions sequentially the result is correct) The trouble appears when some of the child processes die while trying to access to DB , after child dies, parent process always get status code of 1 or 255.. We can reproduce problem but error messages are not the same always ( I attach 3 error log examples) It seems like a previously stablished connection exists to the bd before forking and child processes are working all over it. Anybody can say me how can I force child processes to make their own new connections to de BBDD ? Lots of Thanks!! *EXAMPLE1** ( child status =1)* * ----------------------------------------------------------------------------- ** * *Parent process log* Thu Jul 4 04:23:49 2013,691 [2820] INFO console - root SCHED: *Exited Child PID:2823: STATUS CODE: 1*: SIGN: 0 Thu Jul 4 04:23:49 2013,691 [2820] ERROR console - SCHED:ERROR:Success *Child process log ( process who is dying)* Thu-04/July/2013-04:23:49::[2823] PHP ERROR [2] : mysqli_query(): Protocol error. Server sent false length. Expected 12 Thu-04/July/2013-04:23:49::[2823] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 805 Thu-04/July/2013-04:23:49::[2823] PHP ERROR [2] : Packets out of order. Expected 3 received 67. Packet size=3158064 Thu-04/July/2013-04:23:49::[2823] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 805 Thu-04/July/2013-04:23:49::[2823] PHP ERROR [2] : mysqli_query(): MySQL server has gone away Thu-04/July/2013-04:23:49::[2823] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 805 <die> *EXAMPLE2 ( child status =1)* * ----------------------------------------------------------------------------- * * * *Parent process log * Thu Jul 4 05:50:58 2013,067 [4969] INFO console - root SCHED: *Exited Child PID:4973: STATUS CODE: 1*: SIGN: 0 Thu Jul 4 05:50:58 2013,068 [4969] ERROR console - SCHED:ERROR:Success *Child process log(**process who is dying)* Thu-04/July/2013-05:50:57::[4973] PHP ERROR [2] : mysqli_query(): Premature end of data (mysqlnd_wireprotocol.c:958) Thu-04/July/2013-05:50:57::[4973] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 805 Thu-04/July/2013-05:50:57::[4973] PHP ERROR [2] : mysqli_query(): Result set field packet 27 bytes shorter than expected Thu-04/July/2013-05:50:57::[4973] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 805 <die> *EXAMPLE3 ( child output status=255)* * ----------------------------------------------------------------------------- * *Parent process log * * * Thu Jul 4 06:08:41 2013,591 [5690] INFO console - root SCHED: *Exited Child PID:5696: STATUS CODE: 255: SIGN: 0* Thu Jul 4 06:08:41 2013,592 [5690] ERROR console - SCHED:ERROR:Success *Child process log (**process who is dying)* Thu-04/July/2013-06:08:41::[5696] PHP ERROR [2] : mysqli_query(): Error reading result set's header Thu-04/July/2013-06:08:41::[5696] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 805 Thu-04/July/2013-06:08:41::[5696] PHP ERROR [2] : mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Thu-04/July/2013-06:08:41::[5696] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 1646 Thu-04/July/2013-06:08:41::[5696] PEAR ERROR: MDB2 Error: insufficient data supplied Thu-04/July/2013-06:08:41::[5696] PHP ERROR [2] : mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given Thu-04/July/2013-06:08:41::[5696] PHP ERROR on file /usr/share/php/MDB2/Driver/mysqli.php, line 1414 Thu-04/July/2013-06:08:41::[5696] PEAR ERROR: MDB2 Error: insufficient data supplied Thu-04/July/2013-06:08:41::[5696] PHP ERROR [2] : array_keys() expects parameter 1 to be array, object given Thu-04/July/2013-06:08:41::[5696] PHP ERROR on file /usr/share/php/DB/DataObject.php, line 569 Thu-04/July/2013-06:08:41::[5696] PHP ERROR [2] : array_flip() expects parameter 1 to be array, null given Thu-04/July/2013-06:08:41::[5696] PHP ERROR on file /usr/share/php/DB/DataObject.php, line 569 <die> -- Att Toni Moreno 699706656 *Si no quieres perderte en el olvido tan pronto como estés muerto y corrompido, * *escribe cosas dignas de leerse, o haz cosas dignas de escribirse.* *Benjamin Franklin*