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.
The original patch[1] cared only about pipe handles in the rset, but would be problematic if there are other handles (e.g. files in the rset, or pipes/files in the other sets), because
php_select()
would return immediately, reporting all non read-pipe handles as ready, but possibly never reporting read-pipe handles.We fix this by applying different logic for the case where only pipe handles are supplied in the rset, but no handles in the wset or eset. In this case
php_select()
only returns when actually one of the handles is ready, or when the timeout expires. To avoid busy looping in this case, we sleep for a short amount of time. This matches POSIX behavior.In all other cases,
php_select()
behaves as before (i.e. prior to the original fix), that is it returns immediately, reporting all handles as ready.We also add a test case that demonstrates multiplexing the output of a couple of child processes.
See also the discussion on #16917.
[1] b614b4a
If we merge this, it deservers a mention in UPGRADING.