Get the current handler for specified signal

pcntl_signal_get_handler

(PHP 7 >= 7.1.0, PHP 8)

pcntl_signal_get_handlerGet the current handler for specified signal

說明

pcntl_signal_get_handler(int $signal): callable|int

The pcntl_signal_get_handler() function will get the current handler for the specified signal.

參數

signal

The signal number.

返回值

This function may return an integer value that refers to SIG_DFL or SIG_IGN. If a custom handler has been set, that callable is returned.

更新日誌

版本 說明
7.1.0 pcntl_signal_get_handler() has been added.

範例

示例 #1 pcntl_signal_get_handler() example

<?php
var_dump
(pcntl_signal_get_handler(SIGUSR1)); // Outputs: int(0)

function pcntl_test($signo) {}
pcntl_signal(SIGUSR1'pcntl_test');
var_dump(pcntl_signal_get_handler(SIGUSR1)); // Outputs: string(10) "pcntl_test"

pcntl_signal(SIGUSR1SIG_DFL);
var_dump(pcntl_signal_get_handler(SIGUSR1)); // Outputs: int(0)

pcntl_signal(SIGUSR1SIG_IGN);
var_dump(pcntl_signal_get_handler(SIGUSR1)); // Outputs: int(1)
?>

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *