|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-06-03 09:37 UTC] mariuz@php.net
-Assigned To:
+Assigned To: mariuz
[2012-01-05 09:05 UTC] steffen at kernelguy dot dk
[2012-11-21 08:41 UTC] steffen at kernelguy dot dk
[2017-10-24 06:46 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: mariuz
+Assigned To:
[2019-03-23 16:40 UTC] lester at lsces dot co dot uk
[2021-03-31 11:35 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2021-03-31 11:35 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 07:00:02 2025 UTC |
Description: ------------ After using the pcntl_fork() function both parent and child are not able to connect to the database. Reproduce code: --------------- <?php function dbGet($name) { echo $name.": ".getmypid()."\n"; $dbLogin = 'user'; $dbPassword = 'password'; $dbDB = 'localhost:database'; $dbCharset = 'WIN1251'; $dbDialect = 3; $dbRole = ''; $dbh = ibase_connect($dbDB, $dbLogin, $dbPassword, $dbCharset, 0, $dbDialect, $dbRole); if (!$dbh) { echo $name.": connection error - ".ibase_errmsg()."\n"; posix_kill(getmypid(), 9); } $query = "SELECT * FROM SOMETABLE;"; if (!$dbResult = ibase_query($dbh, $query)) { echo $name.": query error - ".ibase_errmsg()."\n"; posix_kill(getmypid(), 9); } $row = ibase_fetch_row($dbResult); ibase_free_result($dbResult); ibase_commit(); if (empty($row)) echo $name.": row empty - ".ibase_errmsg()."\n"; else echo $name.":\n".print_r($row, true); } // $error_reporting_level = error_reporting(0); // error_reporting($error_reporting_level); error_reporting(0); dbGet('grandpa'); // $this->obj->Log->debug('ReportGeneric before fork ('.getmygid().')'); $pid = pcntl_fork(); if ($pid == -1) die('fork error'); if ($pid) { // PARENT dbGet('parent'); posix_kill(getmypid(), 9); } else { // CHILD dbGet('child'); posix_kill(getmypid(), 9); } ?> Expected result: ---------------- $ php fork_interbase.php grandpa: 27850 grandpa: Array ( [0] => 1 ) child: 27852 child: Array ( [0] => 1 ) parent: 27850 parent: Array ( [0] => 1 ) Killed $ Actual result: -------------- $ php fork_interbase.php grandpa: 27850 grandpa: Array ( [0] => 1 ) child: 27852 parent: 27850 parent: row empty - Unable to complete network request to host "localhost". Error writing data to the connection. Broken pipe child: query error - Unable to complete network request to host "localhost". Error reading data from the connection. Killed $