Fix proc_close() signal exit code handling#21293
Open
alies-dev wants to merge 2 commits intophp:masterfrom
Open
Fix proc_close() signal exit code handling#21293alies-dev wants to merge 2 commits intophp:masterfrom
alies-dev wants to merge 2 commits intophp:masterfrom
Conversation
proc_close() previously returned the raw waitpid status when a child process was killed by a signal, making it impossible to distinguish a signal death from a normal exit with the same code. Now follows the bash convention: return 128 + signal_number for signal-terminated processes (e.g. 139 for SIGSEGV, 143 for SIGTERM). Closes phpGH-21292
PHP catches SIGTERM internally and does exit(255), so the child process never actually dies from the signal. Use /bin/sh with kill -9 (SIGKILL) which cannot be caught.
This was referenced Feb 25, 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.
When a child process spawned via
proc_open()is killed by a signal,proc_close()returns a raw/mangled waitpid status instead of a meaningful exit code. This makes it impossible to distinguish between "exited normally with code 11" and "killed by SIGSEGV".The fix adds proper
WIFSIGNALED()/WTERMSIG()handling inproc_open_rsrc_dtor()(whichproc_close()calls internally), returning128 + signal_number— the same convention used by bash and other shells.proc_get_status()already handled this correctly via itssignaled/termsigfields; only theproc_close()return value was broken.Fixes GH-21292
The bug originally was found by using Psalm vimeo/psalm#11679 that uses
composer/xdebug-handler: composer/xdebug-handler#161