php-ipc/examples/signaltraps.php

24 lines
320 B
PHP

<?php
require_once __DIR__."/../vendor/autoload.php";
use NoccyLabs\Ipc\Signal\SignalTrap;
$trap = new SignalTrap(SIGINT);
echo "Press ctrl-c...\n";
while (!$trap->isTrapped(true)) {
usleep(10000);
}
echo "Thanks!\n";
echo "And once more...\n";
while (!$trap(true)) {
usleep(10000);
}
echo "Thanks!\n";