Skip to content

Add tests for signal death detection via proc_get_status#163

Closed
alies-dev wants to merge 2 commits intocomposer:mainfrom
alies-dev:add-signal-exit-code-test
Closed

Add tests for signal death detection via proc_get_status#163
alies-dev wants to merge 2 commits intocomposer:mainfrom
alies-dev:add-signal-exit-code-test

Conversation

@alies-dev
Copy link

Summary

Adds SignalExitCodeTest as requested in #162 (comment) by @keradus — tests that prove the proc_get_status polling fix is necessary and would fail if reverted.

What the tests prove

  1. testProcCloseReturnsRawSignalNumberproc_close returns raw signal number (15 for SIGTERM), indistinguishable from exit(15)
  2. testProcGetStatusDetectsSignalDeathproc_get_status correctly identifies signal death via signaled/termsig fields, enabling 128 + signal computation
  3. testProcGetStatusDetectsSegfault — Same for SIGSEGV (signal 11 → exit code 139), the most common crash scenario
  4. testProcCloseReturnsRawSignalNumberForSegfaultproc_close alone returns 11, same as exit(11)
  5. testNormalExitCodeIsPreserved — Normal exit codes work correctly with both methods

Tests are skipped on Windows (signals work differently) and when the posix extension is unavailable.

Relationship to #162

This PR provides the test coverage for the fix in #162. It is based on main (not on the detect-crash-signals branch) to clearly show the tests validate the mechanismproc_get_status vs proc_close — independent of the fix itself. The tests can be merged into detect-crash-signals or landed alongside it.

See php/php-src#21292

Add SignalExitCodeTest that demonstrates:
- proc_close returns raw signal numbers (e.g. 15 for SIGTERM, 11 for
  SIGSEGV), indistinguishable from normal exit codes
- proc_get_status polling correctly identifies signal deaths via the
  signaled/termsig fields, enabling the conventional 128+signal exit
  code computation
- Normal exit codes are preserved with both methods

These tests validate the mechanism used in the doRestart() fix
and will fail if that fix is reverted.

See php/php-src#21292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants