Swoole\Process::signal ( string $signal_no , callable $callback ) : bool

Declaration

<?php
Swoole\Process::signal ( string $signal_no , callable $callback ) : bool

Parameters

signal_no

the signal number

callback

the callback function called when the signal is triggered

Return

success

Description

Setup signal callback function.

Example

<?php
Swoole\Process::signal(SIGALRM, function () {
    static $i = 0;
    echo "#{$i}\talarm\n";
    $i++;
    if ($i > 20) {
        Swoole\Process::alarm(-1);
    }
});

//100ms
Swoole\Process::alarm(100 * 1000);