1--TEST-- 2Prevent switching fibers when dispatching pending signals 3--EXTENSIONS-- 4pcntl 5posix 6--FILE-- 7<?php 8 9pcntl_signal(SIGUSR1, function (): void { 10 if (Fiber::getCurrent() !== null) { 11 Fiber::suspend(); 12 } 13}); 14 15$fiber = new Fiber(function (): void { 16 echo "Fiber start\n"; 17 18 posix_kill(posix_getpid(), SIGUSR1); 19 20 try { 21 pcntl_signal_dispatch(); 22 } catch (FiberError $e) { 23 Fiber::suspend($e); 24 } 25 26 echo "Fiber end\n"; 27}); 28 29$e = $fiber->start(); 30 31echo $e, "\n"; 32 33$fiber->resume(); 34 35?> 36--EXPECTF-- 37Fiber start 38FiberError: Cannot switch fibers in current execution context in %ssignal-dispatch.php:%d 39Stack trace: 40#0 %ssignal-dispatch.php(%d): Fiber::suspend() 41#1 [internal function]: {closure}(%d, Array) 42#2 %ssignal-dispatch.php(%d): pcntl_signal_dispatch() 43#3 [internal function]: {closure}() 44#4 %ssignal-dispatch.php(%d): Fiber->start() 45#5 {main} 46Fiber end 47