Repository navigation
Conversation
iliaal
reviewed
Nov 7, 2026
The process resource destructor closed every pipe stream with zend_list_close(), regardless of whether a user filter callback was running on it. Both proc_close() and releasing the last reference to the process from inside such a callback freed the pipe stream and the filter under the running callback. The destructor now only drops its reference to a pipe stream marked PHP_STREAM_FLAG_NO_FCLOSE, so the stream closes with its last reference instead. It also does not wait for the child in that case, as the child may be blocked on the kept open pipe, which would deadlock when the destructor runs nested in another pclose() or proc_close() that still has FG(pclose_wait) set. proc_close() additionally refuses to close the process while one of its pipes carries that flag, since waiting for the child with the pipe still open could deadlock. It warns and returns -1, its documented error value, like pclose() does for such a stream.
bukka
force-pushed
the
proc_close_in_filter
branch
from
November 7, 2026 21:44
3c25aa4 to
0f01ffe
Compare
iliaal
approved these changes
Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 process resource destructor closed every pipe stream with zend_list_close(), regardless of whether a user filter callback was running on it. Both proc_close() and releasing the last reference to the process from inside such a callback freed the pipe stream and the filter under the running callback.
The destructor now only drops its reference to a pipe stream marked PHP_STREAM_FLAG_NO_FCLOSE, so the stream closes with its last reference instead. proc_close() additionally refuses to close the process while one of its pipes carries that flag, since waiting for the child with the pipe still open could deadlock. It warns and returns -1, its documented error value, like pclose() does for such a stream.