Fix zombie process on process destruction - #86
Open
xtrime-ru wants to merge 2 commits into
Open
Conversation
xtrime-ru
force-pushed
the
fix-posix-zombie
branch
4 times, most recently
from
August 25, 2026 21:09
e455beb to
47566d0
Compare
xtrime-ru
force-pushed
the
fix-posix-zombie
branch
from
August 26, 2026 22:21
47566d0 to
ffd4ab3
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
Prevents POSIX wrapper shells created by
proc_open()from remaining as zombie processes when a process is killed or destroyed.Also handles failures returned by
posix_kill()without blocking while waiting for a process that was not terminated.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 PID stored as
$pidbelongs to the command started by the wrapper shell. Waiting for$pidcannot reap$shellPid.Reaping
$shellPidpreviously relied on an event-loop callback. If the event loop did not run after the shell exited, no subsequentwaitpid()call was made and the shell remained a zombie.Additionally,
posix_kill()failures were ignored. A failed signal followed by a blockingwaitpid()could makeProcess::kill()wait for the command to exit naturally.Changes
$shellPidafterkill()and during handle destruction.waitpid()when interrupted byEINTR.posix_kill()fails.ESRCHas successful termination because the OS process has already exited.This completes the POSIX shutdown handling introduced in 6c711ee.
Testing