-
Notifications
You must be signed in to change notification settings - Fork 107
Description
I don't think (based on issues found in the golang repository) that we will see golang support for forking in shared c libraries anytime soon. If you fork and interact with golang objects and functions post-fork, you will eventually deadlock.
For example, in the current example.php:
Take...
test_funcs();
test_classes();
test_inis();
And rewrite it work a fork, based on the example @ https://www.php.net/manual/en/function.pcntl-fork.php
test_funcs();
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
// we are the parent
pcntl_wait($status); //Protect against Zombie children
} else {
$i=0;
while(true) {
test_classes();
echo($i++);
}
}
test_inis();
And you will see fairly quickly, it will deadlock. Here is a GIF:

Knowing that this probably won't fixable anytime soon, and from what I can tell, PHP doesn't offer support for unloading and reloading extensions during forking, maybe we should put up a notice about it in the README? Unless anybody know of a theoretical way around this, which I would be very grateful for.