From: jjoss at mail dot ru
Operating system: Ubuntu Linux 2.6.18
PHP version: 5.2.9
PHP Bug Type: InterBase related
Bug description: After FORK Interbase doesn't work
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
$
--
Edit bug report at http://bugs.php.net/?id=48447&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48447&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48447&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48447&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48447&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48447&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48447&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48447&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48447&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48447&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48447&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48447&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48447&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48447&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48447&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48447&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48447&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48447&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48447&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48447&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48447&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48447&r=mysqlcfg