Limiting scope of signal handling based on environment#220
Limiting scope of signal handling based on environment#220bennothommo wants to merge 2 commits intodevelopfrom
Conversation
- Do not handle Linux signals if the PCNTL extension is unavailable. Artisan commands can still function without this extension - they just simply cannot handle termination signals. - Prevent multiple registrations of the Windows signal handler if the method is called multiple times. - Remove specific checks for Windows signals - the handler only accepts two types of signals (CTRL+C or CTRL+BREAK) and both are termination signals.
|
@bennothommo this looks fine to me, any issues with it going in 1.2.9? Also what's the PHPStan issue? |
|
@LukeTowers no reason not to include it in 1.2.9 if you would prefer. The PHPStan issue seems to have occurred with all pushes recently to Storm - it doesn't seem to be able to correctly work out how our Singletons work. We can probably ignore it for now. |
|
This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days. |
WalkthroughThis change introduces defensive programming to the HandlesCleanup trait by adding state tracking for Windows signal handler registration and guarding signal operations with capability checks. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Areas requiring attention:
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Console/Traits/HandlesCleanup.php (1)
71-87: LGTM!The simplified logic treating all events as termination signals aligns with the PR objectives.
Consider prefixing the unused
$eventparameter with an underscore to signal intent:- public function handleWindowsSignal(int $event): void + public function handleWindowsSignal(int $_event): void
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Console/Traits/HandlesCleanup.php(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: windows-latest / PHP 8.4
- GitHub Check: windows-latest / PHP 8.2
- GitHub Check: windows-latest / PHP 8.3
- GitHub Check: windows-latest / PHP 8.1
🔇 Additional comments (5)
src/Console/Traits/HandlesCleanup.php (5)
17-18: LGTM!The new flag cleanly tracks Windows handler registration state and prevents duplicate registrations as intended.
32-35: LGTM!Good defensive programming: the function existence check and idempotency flag correctly prevent duplicate handler registrations and handle environments where the Windows function is unavailable.
38-40: LGTM!The guard correctly ensures signal constants are only referenced when the PCNTL extension is available, preventing undefined constant errors.
61-63: LGTM!Good defensive check. While
handleSignalshouldn't receive Unix signals when PCNTL is unavailable (sincegetSubscribedSignalsreturns an empty array), this guard ensures robustness if the method is ever called directly.
74-78: LGTM!The flag-guarded removal logic is properly paired with the registration logic, ensuring the handler is only removed if it was previously registered.
|
This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days. |
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.