1--TEST--
2pcntl_sigprocmask() errors
3--EXTENSIONS--
4pcntl
5--SKIPIF--
6<?php if (!function_exists("pcntl_sigprocmask")) die("skip pcntl_sigprocmask() not available"); ?>
7--INI--
8max_execution_time=0
9--FILE--
10<?php
11
12/* Invalid mode */
13try {
14    $signals = [SIGTERM];
15    $signal_no = pcntl_sigprocmask(-1, $signals);
16    var_dump($signal_no);
17} catch (\Throwable $e) {
18    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
19}
20try {
21    /* This used to return -1 prior to PHP 8.4.0 */
22    $signals = [];
23    $signal_no = pcntl_sigprocmask(SIG_BLOCK, $signals);
24    var_dump($signal_no);
25} catch (\Throwable $e) {
26    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
27}
28
29try {
30    $signals = [0];
31    $signal_no = pcntl_sigprocmask(SIG_BLOCK, $signals);
32    var_dump($signal_no);
33} catch (\Throwable $e) {
34    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
35}
36try {
37    $signals = [-1];
38    $signal_no = pcntl_sigprocmask(SIG_BLOCK, $signals);
39    var_dump($signal_no);
40} catch (\Throwable $e) {
41    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
42}
43
44try {
45    $signals = ["not a signal"];
46    $signal_no = pcntl_sigprocmask(SIG_BLOCK, $signals);
47    var_dump($signal_no);
48} catch (\Throwable $e) {
49    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
50}
51
52/* Unlikely valid signal */
53try {
54    $signals = [2**10];
55    $signal_no = pcntl_sigprocmask(SIG_BLOCK, $signals);
56    var_dump($signal_no);
57} catch (\Throwable $e) {
58    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
59}
60?>
61--EXPECTF--
62ValueError: pcntl_sigprocmask(): Argument #1 ($mode) must be one of SIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK
63ValueError: pcntl_sigprocmask(): Argument #2 ($signals) must not be empty
64ValueError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be between 1 and %d
65ValueError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be between 1 and %d
66TypeError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be of type int, string given
67ValueError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be between 1 and %d
68