-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning: shmop_open(): unable to attach or create shared memory segment 'No space left on device' #16
Comments
So the problem only occurs when throwing exceptions? I think I can see how that would happen, I'll take a look at reproducing and resolving |
Hmm I'm unable to reproduce the problem, please can you provide a script that demonstrates the issue? |
So here is the code to reproduce: <?php
require 'vendor/autoload.php';
use duncan3dc\Forker\Fork;
$fork = new Fork();
$fork->call(function () {
for ($i = 1; $i <= 3; $i++) {
echo "Process A - " . $i . "\n";
sleep(1);
}
});
$fork->call(function () {
for ($i = 1; $i < 3; $i++) {
echo "Process B - " . $i . "\n";
sleep(1);
}
});
throw new Exception();
sleep(1);
echo "Waiting for the threads to finish...\n";
$fork->wait();
echo "End\n"; Running this code for 10 to 20 times will end in a Exception |
Hi @Moskito89, you'll need a try/catch around your code to make sure you call Right now when a thread ends we don't know if others are still running, so we don't know when it's safe to clean up the shared memory, only the Another option would be to refactor so that everything is done in |
I understand this logic and the problem behind it. But if we'd use a shutdown function we could get sure, that the execution of this script always clears the shared memory, even when the execution fails/exits at some place. Wouldn't it be useful that way? |
I'd expect the shutdown function would be called within the threads too, thus deleting the shared memory early. You could perhaps register one after calling I'll leave the issue open for now, and try out a few things when I get some time 👍 |
This problem still exists in v2.3.0.
I was playing around with the sample code here and also had some errors and Exceptions, made by my own. When receiving those the script finishes without calling the
cleanup()
method. I belive that this causes the problem.The text was updated successfully, but these errors were encountered: