#552 Move signal handling from queue component to controller#553
#552 Move signal handling from queue component to controller#553snewer wants to merge 2 commits intoyiisoft:masterfrom
Conversation
snewer
commented
Mar 3, 2026
| Q | A |
|---|---|
| Is bugfix? | ✔️ |
| New feature? | ❌ |
| Breaks BC? | ❌ |
| Tests pass? | ✔️ |
| Fixed issues | #552 |
I just moved the code, but yes, I agree it’s unnecessary here, so I removed it |
The PHP 7.1 code is also unnecessary. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #553 +/- ##
============================================
- Coverage 46.54% 45.98% -0.57%
Complexity 506 506
============================================
Files 44 44
Lines 1579 1581 +2
============================================
- Hits 735 727 -8
- Misses 844 854 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses #552 by preventing the AMQP Interop queue component from overriding process-wide UNIX signal handlers during application bootstrap, moving that behavior into the AMQP Interop console command lifecycle instead.
Changes:
- Removed pcntl signal handler registration from
amqp_interop\Queue::init()to avoid global side effects at bootstrap. - Added signal handler registration to
amqp_interop\Command::init()so it only applies when the AMQP Interop queue command runs. - Documented the change in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/drivers/amqp_interop/Queue.php | Stops registering signal handlers during component bootstrap to avoid impacting unrelated console commands. |
| src/drivers/amqp_interop/Command.php | Registers signal handlers at command init time so behavior is scoped to the AMQP Interop CLI command execution. |
| CHANGELOG.md | Adds an entry describing the signal-handling relocation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| pcntl_signal($signal, SIG_DFL); | ||
| posix_kill(posix_getpid(), $signal); |
There was a problem hiding this comment.
The signal handler unconditionally calls posix_kill(posix_getpid(), $signal), but ext-posix isn’t required (composer.json only suggests ext-pcntl). In environments where pcntl_signal exists but posix functions are unavailable, this will fatal when a signal is received. Consider guarding with function_exists('posix_kill'), using getmypid() instead of posix_getpid(), and providing a safe fallback (e.g., exiting with a non-zero status) when posix_kill isn’t available.
| posix_kill(posix_getpid(), $signal); | |
| if (function_exists('posix_kill')) { | |
| posix_kill(getmypid(), $signal); | |
| } else { | |
| // Fallback when POSIX functions are unavailable. | |
| exit(1); | |
| } |
| - Enh #503: All dependent packages for supported drivers have been updated to the latest versions (@s1lver) | ||
| - Enh #503: The `opis/closure` package did not support PHP 8.1 and was replaced by the `laravel/serializable-closure` package (@s1lver) | ||
| - Enh #544: Applying Yii2 coding standards (@s1lver) | ||
| - Enh #552: Move signal handling from AMQP Interop queue component to controller (@snewer) |
There was a problem hiding this comment.