Fix finished process handling in PHP 8.1.22/8.2.9 #212
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm not sure if this even should be merged since it will probably be obsolete in a few weeks, but currently, this library is broken in the latest PHP versions 8.1.22 and 8.2.9 due to this change: php/php-src#11509
From what I understand, without this change,
SIGCHILD
is received inconsistently sopcntl_waitpid()
is used to correctly check finished child processes. With this change,SIGCHILD
is received consistently, butpcntl_waitpid()
doesn't return those processes after that, maybe because they are already considered handled?Therefore in PHP 8.1.22 and 8.2.9, the finished processes are never handled and the waiting process hangs indefinitely. Because this is BC breaking, this was already reverted in PHP and will be back to the previous behavior in future PHP versions: php/php-src#11863
I've added special handling for only the affected PHP versions, where the
SIGCHILD
is handled immediately withoutpcntl_waitpid()
. All other PHP versions should have the same behavior as before. I'm not sure if that's the best fix, but the tests pass in PHP 8.2.9.