php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30805 broken db connection lost after fork
Submitted: 2004-11-16 14:56 UTC Modified: 2005-02-23 21:33 UTC
From: rui dot francisco at fccn dot pt Assigned:
Status: Not a bug Package: InterBase related
PHP Version: 5.0.2 OS: linux kernel 2.4.22
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rui dot francisco at fccn dot pt
New email:
PHP Version: OS:

 

 [2004-11-16 14:56 UTC] rui dot francisco at fccn dot pt
Description:
------------
i query a db (firebird 1.5.1)for a resultset
I use a loop to go to all the records
in the record processing i fork ()
  in there i use shell_exec with the no hup
  terminate the child

in the parent i verify a log file
if the string i want is there i kill the child
wait for the child

when i try to update the db using the same db connection, or one new its reports a broken pipe

The script was originally built using Pear DB, but i change it to ibase function to garante that wasn't a Pear DB bug.

I compiled php with the following configuration

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-ssl --with-libxml --with-interbase=/opt/firebird --with-pear --with-zlib --enable-sockets --enable-track-vars --enable-pcntl -enable-debug


My compiled modules
root@host:/usr/src/php-5.0.2# php -m
[PHP Modules]
ctype
dom
iconv
interbase
libxml
pcntl
pcre
posix
session
SimpleXML
sockets
SPL
SQLite
standard
tokenizer
xml
zlib



Thanks in advance
Rui Francisco

Reproduce code:
---------------
$pid=pcntl_fork();

if ($pid == -1) 
	{
		 echo "Erro ao efectuar o fork\n";
	} 
else if ($pid) 
	{
		// we are the parent
		$resultado='-----';
		//sleep(4);
		while ($resultado=='-----') {
			sleep(2);
			$a=shell_exec("cat xsupplicant.log");
			
			if (strpos($a,'Failure',0)) {
				$resultado='SC';
				shell_exec('ifconfig '.$vInterface.' down');
				shell_exec('killall xsupplicant');
				sleep(2);
				shell_exec('ifconfig '.$vInterface.' up');
			}					
			if (strpos($a,'Authenticated',0))
				$resultado='A';
		}
		pcntl_wait($status);
	} 
else 
	{
		// we are the child
		ob_start();
		shell_exec('killall xsupplicant 2>&1');
		shell_exec('rm /var/run/xsupplicant 2>&1');
		ob_end_clean();
		sleep(1);
		$a=shell_exec("nohup xsupplicant -c conf_teste.conf -i ".$vInterface." & ");
		exit (0);
	}

echo $vDominio." - ".$resultado."\n";



Expected result:
----------------
update the database, no message

Actual result:
--------------
Warning: ibase_query(): Unable to complete network request to host "localhost". Error writing data to the connection. Broken pipe  in /web/roam/test_connectivity.php on line 210
Unable to complete network request to host "localhost". Error writing data to the connection. Broken pipe

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-13 22:26 UTC] abies@php.net
Please provide an example that actually contains ibase_*() functions.
 [2005-02-23 21:33 UTC] abies@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 00:01:29 2024 UTC