note 93466 added to function.pcntl-fork
| From: | php at mx dot magic-lamp dot org | Date: | Fri, 11 Sep 2009 08:31:17 +0000 |
| Subject: | note 93466 added to function.pcntl-fork | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160444@lists.php.net to get a copy of this message | ||
A workaround for the MySQL "Lost Connection during query", or any other object related
problems caused by children exiting is to force the child to kill -9 itself, thus avoiding any
cleanup. Sure - it's not too elegant, but it does work.
<?php
$pid = pcntl_fork();
if ( $pid == 0 ) {
// This is the child process. Do something here.
// Instead of calling exit(), we use posix_kill()
posix_kill(getmypid(),9);
}
?>
Watch out that you don't spawn too many processes though as this creates its own problems.
----
Server IP: 91.199.167.18
Probable Submitter: 94.100.112.225
----
Manual Page -- http://www.php.net/manual/en/function.pcntl-fork.php
Edit -- https://master.php.net/note/edit/93466
Del: integrated -- https://master.php.net/note/delete/93466/integrated
Del: useless -- https://master.php.net/note/delete/93466/useless
Del: bad code -- https://master.php.net/note/delete/93466/bad+code
Del: spam -- https://master.php.net/note/delete/93466/spam
Del: non-english -- https://master.php.net/note/delete/93466/non-english
Del: in docs -- https://master.php.net/note/delete/93466/in+docs
Del: other reasons-- https://master.php.net/note/delete/93466
Reject -- https://master.php.net/note/reject/93466
Search -- https://master.php.net/manage/user-notes.php