1--TEST--
2pcntl_sigwaitinfo() errors
3--EXTENSIONS--
4pcntl
5--SKIPIF--
6<?php if (!function_exists("pcntl_sigwaitinfo")) 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_sigwaitinfo($signals, $signal_infos);
16    var_dump($signal_no);
17} catch (\Throwable $e) {
18    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
19}
20
21try {
22    $signals = [0];
23    $signal_no = pcntl_sigwaitinfo($signals, $signal_infos);
24    var_dump($signal_no);
25} catch (\Throwable $e) {
26    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
27}
28try {
29    $signals = [-1];
30    $signal_no = pcntl_sigwaitinfo($signals, $signal_infos);
31    var_dump($signal_no);
32} catch (\Throwable $e) {
33    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
34}
35
36try {
37    $signals = ["not a signal"];
38    $signal_no = pcntl_sigwaitinfo($signals, $signal_infos);
39    var_dump($signal_no);
40} catch (\Throwable $e) {
41    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
42}
43
44/* Unlikely valid signal */
45try {
46    $signals = [2**10];
47    $signal_no = pcntl_sigwaitinfo($signals, $signal_infos);
48    var_dump($signal_no);
49} catch (\Throwable $e) {
50    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
51}
52?>
53--EXPECTF--
54ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) must not be empty
55ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be between 1 and %d
56ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be between 1 and %d
57TypeError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, string given
58ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be between 1 and %d
59