Closed Appla closed 2 months ago
In coroutines, fork or Swoole\Process cannot be used, otherwise the coroutine context will be duplicated.
In coroutines, fork or Swoole\Process cannot be used, otherwise the coroutine context will be duplicated.
The above example is intended to trigger swoole_fatal_error
to demonstrate the issue.
The swoole_fatal_error
is triggered, which indicates that it is not a runtime error, there is a problem with your code, you must modify the code.
swoole_fatal_error cannot be caught, and the program will exit immediately.
With the following codes,
php_request_shutdown
will be called inPHP 7.4 + Swoole 4.8.x
but not inPHP 8.3 + Swoole 5.1.x
. Is this expected behavior?Outputs:
PHP 8.3 + 5.1.3
Fatal error: Uncaught Swoole\Error: must be forked outside the coroutine in /path/to/test.php:8 Stack trace:
0 /path/to/test.php(8): Swoole\Process->start()
1 [internal function]: {closure}()
2 {main}
thrown in /path/to/test.php on line 8
before PHP Fatal error: Uncaught Swoole\Error: must be forked outside the coroutine in /path/to/test.php:8 Stack trace:
0 /path/to/test.php(8): Swoole\Process->start()
1 {main}
thrown in /path/to/test.php on line 8 register_shutdown_function called