note 34326 added to function.pcntl-fork
| From: | porkchop at porkchop dot net | Date: | Wed, 23 Jul 2003 23:58:31 +0000 |
| Subject: | note 34326 added to function.pcntl-fork | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52529@lists.php.net to get a copy of this message | ||
On a fork, vars themselves are copied into the new child's space, not just a refrence to that
var.
Consider:
<?
$foo="foo";
$pid=pcntl_fork();
if($pid != 0) { /* we're here if this is the parent */
$foo="bar";
echo $foo; // returns "bar".
die("Child complete");
} else { /* we're the child */
sleep 5
echo $foo; // returns "foo" even though the parent set $foo to "bar" about 5
seconds earlier.
};
?>
----
Manual Page -- http://www.php.net/manual/en/function.pcntl-fork.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34326
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34326&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34326&report=yes