Skip to content

Conversation

@alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Mar 26, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? no
Tickets NA
License MIT
Doc PR No need I guess

Makes me think that adding a similar method to check a signal existence as a string in SignalRegistry could be leveraged in #49750

@lyrixx
Copy link
Member

lyrixx commented Mar 26, 2023

Are we sure the signal list is finite?

@alexandre-daubois
Copy link
Member Author

@lyrixx I tried this snippet:

<?php

function sig_handler($signo)
{
     switch ($signo) {
         default:
     }
}

echo "Installing signal handler";

// setup signal handlers
pcntl_signal(66,  "sig_handler");

And here is the result:

Installing signal handlerPHP Fatal error:  Uncaught ValueError: pcntl_signal(): Argument #1 ($signal) must be less than 65 in /home/alex/signals.php:13
Stack trace:
#0 /home/alex/signals.php(13): pcntl_signal()
#1 {main}
  thrown in /home/alex/signals.php on line 15

So we should at least check that the signal number is lower than 65.
Checking that the given signal is defined in the extension comes from this comment from Nicolas: #49750 (comment). What do you think?

@lyrixx
Copy link
Member

lyrixx commented Mar 27, 2023

I think we should not enforce something that PHP allow. So 👍 with checking only if the number is lower than 65

@lyrixx lyrixx closed this Mar 27, 2023
@lyrixx lyrixx reopened this Mar 27, 2023
@alexandre-daubois alexandre-daubois force-pushed the signalable-command-valid-signals branch from 79bb9bd to 3430e1e Compare March 27, 2023 13:55
@alexandre-daubois
Copy link
Member Author

I updated the SignalRegistry to check if the signal code is less than 32. Indeed, pcntl_signal_get_handler() in SignalRegistry if the signal code is above 31.

I also added a few tests for SignalRegistry.

…` commands are defined in the PCNTL extension
@alexandre-daubois alexandre-daubois force-pushed the signalable-command-valid-signals branch 3 times, most recently from f386e40 to 3da83d0 Compare March 27, 2023 14:00
fabpot added a commit that referenced this pull request Mar 27, 2023
…n messages (alexandre-daubois)

This PR was merged into the 6.3 branch.

Discussion
----------

[Console][DoctrineBridge] Remove backticks from exception messages

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | _NA_
| License       | MIT
| Doc PR        | _NA_

Follow-up of #49822 (comment), removes backticks of a few exception messages.

Commits
-------

1c4b9e6 [Console][DoctrineBridge][PhpUnitBridge] Remove backticks from exception messages
@nicolas-grekas
Copy link
Member

Fatal error: Uncaught ValueError: pcntl_signal(): Argument #1 ($signal) must be less than 65 in /home/alex/signals.php:13

So, there is no need to add code to handle this, since the engine already has an appropriate behavior for invalid signals, isn't it?

@lyrixx
Copy link
Member

lyrixx commented Apr 19, 2023

less code == less bug. I agree with @nicolas-grekas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants