ConFoo Montreal 2026: Call for Papers

Voting

: zero plus zero?
(Example: nine)

The Note You're Voting On

php at mx dot magic-lamp dot org
15 years ago
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.

<< Back to user notes page

To Top