#18775 [Opn->Bgs]: Conflict with variables between father and child
| From: | jason@php.net | Date: | Sat, 24 Aug 2002 04:00:28 +0000 |
| Subject: | #18775 [Opn->Bgs]: Conflict with variables between father and child | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-17738@lists.php.net to get a copy of this message | ||
ID: 18775
Updated by: jason@php.net
Reported By: bariou@brasnah.com
-Status: Open
+Status: Bogus
Bug Type: POSIX related
Operating System: Linux
PHP Version: 4.2.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Processes do not share memory, they are completly independant of each
other. After the fork, a parent can not modify a childs memory area,
and a child can not modify a parent's memory area. You either rethink
your design, use shared memory, or use sockets for interprocess
communication
-Jason
Previous Comments:
------------------------------------------------------------------------
[2002-08-07 05:40:02] bariou@brasnah.com
I work with the pcntl extension and sockets, and I'm working on the
developpement of a multiuser server. Several clients can connect
limited to FD_SIZE. I start by a setup :
//Setup of the sockets
....
//Setup of the client array
$i=0;
while($i<FD_SETSIZE){
$client[$i]=null;
$i++;
}
while(1){
Here the parent cheks connection
$new_socket=socket_accept(main_socket);
It accepts and puts the new socket ressource in the first free slot of
the array client
....
$client[$k]=$new_socket
.....
if(!pcntl_fork){
Child here.....
Manage the dialog its OK ! with several connection
....
but when I shutdown a connection, exit is correct
... I need to remove the linked ressources from
$client[$slot] and it is the same for the select
array...
So I do $client[$slot]=null;
.... But It seems to fail, and each time the parent
continues to see the allocate ressources, so it
refuses more connexion, because $client[$slot] is
not change from the parent point of view.
}//En child
}//
Where I'm wrong, is there a bug for variables between parent and child
? Or maybe I make a confusion for the way
to remove ressources from my client array (value or references) ?
So, now I'm lost, Could somebody gives me some help about please ? I
can send all the code if necessary !
Thanks for your help
Marcel
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18775&edit=1