[php-src] Issue #10951: Error "Cannot switch fibers" when creating a fiber in pcntl_signal
| From: | Provoker | Date: | Mon, 27 Mar 2023 08:58:47 +0000 |
| Subject: | [php-src] Issue #10951: Error "Cannot switch fibers" when creating a fiber in pcntl_signal | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244018@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10951
Author: Provoker
### Description
Since version 8.2.0 when trying to create fiber in a function passed to pcntl_signal an "Cannot
switch fibers in current execution context" error occurs.
The documentation says only about limitation in the destructor.
The following code:
```php
<?php
pcntl_signal(SIGINT, function () {
$fiber = new Fiber(function () {
Fiber::suspend('test');
});
var_dump($fiber->start());
});
posix_kill(getmypid(), SIGINT);
pcntl_signal_dispatch();
```
Resulted in this output:
```
string(4) "test"
```
But I expected this output instead:
```
Uncaught FiberError: Cannot switch fibers in current execution context
```
### PHP Version
PHP 8.2.0
### Operating System
_No response_