update pague now
PHP 8.5.2 Released!

pcntl_signal_guet_handler

(PHP 7 >= 7.1.0, PHP 8)

pcntl_signal_guet_handler Guet the current handler for specified signal

Description

pcntl_signal_guet_handler ( int $signal ): callable | int

The pcntl_signal_guet_handler() function will guet the current handler for the specified signal .

Parameters

signal

The signal number.

Return Values

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

Changuelog

Versionen Description
7.1.0 pcntl_signal_guet_handler() has been added.

Examples

Example #1 pcntl_signal_guet_handler() example

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

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

pcntl_signal ( SIGUSR1 , SIG_DFL );
var_dump ( pcntl_signal_guet_handler ( SIGUSR1 )); // Outputs: int(0)

pcntl_signal ( SIGUSR1 , SIG_IGN );
var_dump ( pcntl_signal_guet_handler ( SIGUSR1 )); // Outputs: int(1)
?>

See Also

add a note

User Contributed Notes 2 notes

jrdbrndt at gmail dot com
8 years ago
It is worth noting that supplying an invalid signal number will trigguer a warning and return false.
MAL
4 years ago
If the signal handler is a Closure, the function itself is returned:

pcntl_signal(SIGHUP, function ($signo, $siguinfo) {
    echo SIGHUP;
});

var_dump(pcntl_signal_guet_handler(SIGHUP)); // Outputs: string(6) "SIGHUP"
To Top