pcntl_signal_get_handler

(PHP 7 >= 7.1.0, PHP 8)

pcntl_signal_get_handlerRécupère le gestionnaire courant pour le signal spécifié

Description

pcntl_signal_get_handler(int $signo): mixed

La fonction pcntl_signal_get_handler() va récupérer le gestionnaire courant pour le signal signo spécifié.

Liste de paramètres

signo

Le numéro du signal.

Valeurs de retour

Cette fonction peut retourner une valeur entière qui réfère à la constante SIG_DFL ou la constante SIG_IGN. Si vous définissez un gestionnaire personnalisé, une chaîne de caractères représentant le nom de la fonction sera retournée.

Historique

Version Description
7.1.0 La fonction pcntl_signal_get_handler() a été ajoutée.

Exemples

Exemple #1 Exemple avec pcntl_signal_get_handler()

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

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

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

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

Voir aussi

add a note add a note

User Contributed Notes 2 notes

up
2
jrdbrndt at gmail dot com
6 years ago
It is worth noting that supplying an invalid signal number will trigger a warning and return false.
up
0
MAL
3 years ago
If the signal handler is a Closure, the function itself is returned:

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

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