Draft: Fix zombie process on process destruction - #86
Open
xtrime-ru wants to merge 3 commits into
Open
Conversation
xtrime-ru
force-pushed
the
fix-posix-zombie
branch
5 times, most recently
from
August 26, 2026 22:21
47566d0 to
ffd4ab3
Compare
xtrime-ru
force-pushed
the
fix-posix-zombie
branch
from
August 28, 2026 15:17
ffd4ab3 to
5c32f9f
Compare
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.
Summary
Ensures that the POSIX wrapper shell created by
proc_open()is reaped after process termination, both with and withoutext-pcntl.Shutdown remains non-blocking while the requested command is still running.
Root cause
proc_get_status($proc)['pid'], stored as$shellPid, identifies the wrapper shell created byproc_open(). This shell is a direct child of PHP.The requested command PID, stored as
$pid, belongs to a process started by the wrapper shell. It is not a direct child of PHP, so waiting for$pidcannot reap the wrapper shell.Shell reaping was deferred through the event loop. If the event loop did not run again after the shell exited, the shell remained a zombie. When
ext-pcntlwas unavailable, the cleanup path returned without performing any wait operation.A blocking reap after
kill()also requires checking signal delivery first.ESRCHmeans that the requested process has already exited and the wrapper shell can still be reaped. Other delivery errors must be reported instead of proceeding to a potentially blocking wait.Changes
posix_kill()failures, treatingESRCHas an already-exited process and throwing for other errors.$shellPidafterkill()and after completed process destruction.pcntl_waitpid()withEINTRhandling when PCNTL is available.proc_get_status()to reap the wrapper shell when PCNTL is unavailable.This corrects the POSIX shutdown handling introduced in 6c711ee.
Testing