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
Links
PCNTL
- pcntl_alarm
- pcntl_errno
- pcntl_exec
- pcntl_fork
- pcntl_get_last_error
- pcntl_getpriority
- pcntl_rfork
- pcntl_setpriority
- pcntl_signal
- pcntl_signal_dispatch
- pcntl_signal_get_handler
- pcntl_sigprocmask
- pcntl_sigtimedwait
- pcntl_sigwaitinfo
- pcntl_strerror
- pcntl_unshare
- pcntl_wait
- pcntl_waitpid
- pcntl_wexitstatus
- pcntl_wifexited
- pcntl_wifsignaled
- pcntl_wifstopped
- pcntl_wstopsig
- pcntl_wtermsig