1--TEST-- 2pcntl_sigtimedwait() errors 3--EXTENSIONS-- 4pcntl 5--SKIPIF-- 6<?php if (!function_exists("pcntl_sigtimedwait")) die("skip pcntl_sigtimedwait() not available"); ?> 7--INI-- 8max_execution_time=0 9--FILE-- 10<?php 11 12try { 13 /* This used to return -1 prior to PHP 8.4.0 */ 14 $signals = []; 15 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, 2); 16 var_dump($signal_no); 17} catch (\Throwable $e) { 18 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 19} 20 21/* Invalid signal numbers */ 22try { 23 $signals = [0]; 24 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, 2); 25 var_dump($signal_no); 26} catch (\Throwable $e) { 27 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 28} 29try { 30 $signals = [-1]; 31 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, 2); 32 var_dump($signal_no); 33} catch (\Throwable $e) { 34 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 35} 36try { 37 $signals = [2**10]; 38 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, 2); 39 var_dump($signal_no); 40} catch (\Throwable $e) { 41 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 42} 43 44/* Invalid signal type */ 45try { 46 $signals = ["not a signal"]; 47 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, 2); 48 var_dump($signal_no); 49} catch (\Throwable $e) { 50 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 51} 52 53/* Invalid (nano)second values */ 54$signals = [SIGTERM]; 55try { 56 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, -1); 57 var_dump($signal_no); 58} catch (\Throwable $e) { 59 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 60} 61try { 62 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, 1, -1); 63 var_dump($signal_no); 64} catch (\Throwable $e) { 65 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 66} 67try { 68 $signal_no = pcntl_sigtimedwait($signals, $signal_infos, 1, PHP_INT_MAX); 69 var_dump($signal_no); 70} catch (\Throwable $e) { 71 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 72} 73try { 74 $signal_no = var_dump(pcntl_sigtimedwait([SIGTERM], $signal_infos, 0, 0)); 75 var_dump($signal_no); 76} catch (\Throwable $e) { 77 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 78} 79/* 1_000_000_000ns = 1s so must throw */ 80try { 81 $signal_no = var_dump(pcntl_sigtimedwait([SIGTERM], $signal_infos, 0, 1_000_000_000)); 82 var_dump($signal_no); 83} catch (\Throwable $e) { 84 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 85} 86 87?> 88--EXPECTF-- 89ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) must not be empty 90ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be between 1 and %d 91ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be between 1 and %d 92ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be between 1 and %d 93TypeError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be of type int, string given 94ValueError: pcntl_sigtimedwait(): Argument #3 ($seconds) must be greater than or equal to 0 95ValueError: pcntl_sigtimedwait(): Argument #4 ($nanoseconds) must be between 0 and 1e9 96ValueError: pcntl_sigtimedwait(): Argument #4 ($nanoseconds) must be between 0 and 1e9 97ValueError: pcntl_sigtimedwait(): At least one of argument #3 ($seconds) or argument #4 ($nanoseconds) must be greater than 0 98ValueError: pcntl_sigtimedwait(): Argument #4 ($nanoseconds) must be between 0 and 1e9 99