Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

pcntl_async_signals

Description

The pcntl_async_signals of PCNTL for PHP enables or disables asynchronous signal handling or returns the old setting.

Syntax

pcntl_async_signals(
    ?bool $enable = null
): bool

Parameters

enable

Whether asynchronous signal handling should be enabled.

Return

When used as getter (enable parameter is null), it returns whether asynchronous signal handling is enabled.

When used as setter (enable parameter is not null), it returns whether asynchronous signal handling was enabled before the function call.

Examples

1 · void · false

<?

$enable = false;

pcntl_async_signals($enable);

$return = pcntl_async_signals();

var_export($return);

?>
false

2 · void · true

<?

$enable = true;

pcntl_async_signals($enable);

$return = pcntl_async_signals();

var_export($return);

?>
true

3 · enable · false

<?

$enable = false;

$return = pcntl_async_signals($enable);

var_export($return);
echo PHP_EOL;

function handler($signo, $siginfo)
{
    print_r($siginfo);
}

$signal = SIGHUP;
$handler = "handler";

pcntl_signal($signal, $handler);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$return = pcntl_async_signals($enable);

var_export($return);

?>
false
false

4 · enable · true

<?

$enable = true;

$return = pcntl_async_signals($enable);

var_export($return);
echo PHP_EOL;

function handler($signo, $siginfo)
{
    print_r($siginfo);
}

$signal = SIGHUP;
$handler = "handler";

pcntl_signal($signal, $handler);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$return = pcntl_async_signals($enable);

var_export($return);

?>
false
Array
(
    [signo] => 1
    [errno] => 0
    [code] => 0
)
true
HomeMenu