Skip to content

Conversation

TysonAndre
Copy link
Contributor

@TysonAndre TysonAndre commented Aug 25, 2019

Backported from d95c15e - PHP 7.1 was also affected but is only receiving security support

  • This was the only edit in that change that added a missing type

This can also return an array. See
https://www.php.net/manual/en/function.time-nanosleep.php#refsect1-function.time-nanosleep-returnvalues

If the delay was interrupted by a signal, an associative array will be
returned with the components:

  • seconds - number of seconds remaining in the delay
  • nanoseconds - number of nanoseconds remaining in the delay

Sending a SIGUSR1 to the below program would trigger this behavior.

pcntl_signal(\SIGUSR1, function ($signo, $signinfo) {
    echo "Handling a signal $signo\n";
});
echo "Sleeping for 100 seconds\n";
var_export(time_nanosleep(100, 0));

The incomplete signature existed since c88ffa9.
No phpt tests existed for time_nanosleep returning an array


Also fix signature for passthru

Backported from a1a8d14
https://www.php.net/manual/en/function.passthru.php#refsect1-function.passthru-returnvalues

passthru() is false with invalid args
passthru('valid or invalid command') is null.

This can also return an array. See
https://www.php.net/manual/en/function.time-nanosleep.php#refsect1-function.time-nanosleep-returnvalues

> If the delay was interrupted by a signal, an associative array will be
returned with the components:
>
> - seconds - number of seconds remaining in the delay
> - nanoseconds - number of nanoseconds remaining in the delay

Sending a SIGUSR1 to the below program would trigger this behavior.

```
pcntl_signal(\SIGUSR1, function ($signo, $signinfo) {
    echo "Handling a signal $signo\n";
});
echo "Sleeping for 100 seconds\n";
var_export(time_nanosleep(100, 0));
```

The incomplete signature existed since c88ffa9.
No phpt tests existed for time_nanosleep returning an array
Backported from a1a8d14
https://www.php.net/manual/en/function.passthru.php#refsect1-function.passthru-returnvalues

`passthru()` is false with invalid args
`passthru('command')` is null.
@TysonAndre TysonAndre changed the title Fix opcache optimizer info for time_nanosleep Fix opcache optimizer info for time_nanosleep+passthru Aug 25, 2019
@nikic
Copy link
Member

nikic commented Aug 26, 2019

Merged as f5bccc0 and 1e82a2d. Thanks!

@nikic nikic closed this Aug 26, 2019
TysonAndre added a commit to TysonAndre/php-src that referenced this pull request Sep 3, 2019
Fixes my earlier PR php#4617

If I remember correctly,
The F0 macro is used for return values that are guaranteed to not be
reference counted.
The F1 macro is used for return values that may have up to 1 reference
(i.e. MAY_BE_RC1).

I didn't notice that time_nanosleep needed to be F1 since it could
return an array, and that array is reference counted.
php-pulls pushed a commit that referenced this pull request Sep 3, 2019
Fixes my earlier PR #4617

If I remember correctly,
The F0 macro is used for return values that are guaranteed to not be
reference counted.
The F1 macro is used for return values that may have up to 1 reference
(i.e. MAY_BE_RC1).

I didn't notice that time_nanosleep needed to be F1 since it could
return an array, and that array is reference counted.
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