note 99369 added to function.pcntl-fork

From: Date: Fri, 13 Aug 2010 02:33:23 +0000
Subject: note 99369 added to function.pcntl-fork
Groups: php.notes 
Request: Send a blank email to php-notes+get-171633@lists.php.net to get a copy of this message
There are quite a few questions regarding how file descriptors get handled when processes are forked. Remember that fork() makes a copy of the program, which means all descriptors are copied. Unfortunately, this is a rather bad situation for a PHP program because most descriptors are handled by PHP or a PHP Extension internally. The simple, and probably "proper" way to solve this issue is to fork before hand, there really should be no need to fork at many different points among a program, you would simply fork, and then delegate the work. Use a master/worker hierarchy. For example, if you need to have many processes that use a MySQL Connection, just fork before the connection is made, that way each child has it´s own connection to mysql that it, and it alone, manages. With careful and correct usage, fork() can be an extremely powerful tool. --Please remember to take proper care of your children. ---- Server IP: 69.147.83.197 Probable Submitter: 96.45.180.110 (proxied: 127.0.0.1) ---- Manual Page -- http://www.php.net/manual/en/function.pcntl-fork.php Edit -- https://master.php.net/note/edit/99369 Del: integrated -- https://master.php.net/note/delete/99369/integrated Del: useless -- https://master.php.net/note/delete/99369/useless Del: bad code -- https://master.php.net/note/delete/99369/bad+code Del: spam -- https://master.php.net/note/delete/99369/spam Del: non-english -- https://master.php.net/note/delete/99369/non-english Del: in docs -- https://master.php.net/note/delete/99369/in+docs Del: other reasons-- https://master.php.net/note/delete/99369 Reject -- https://master.php.net/note/reject/99369 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171633) next »