ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
NonStopableProcess.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
19function handleSignal($signal)
20{
21 switch ($signal) {
22 case SIGTERM:
23 $name = 'SIGTERM';
24 break;
25 case SIGINT:
26 $name = 'SIGINT';
27 break;
28 default:
29 $name = $signal.' (unknown)';
30 break;
31 }
32
33 echo "signal $name\n";
34}
35
36pcntl_signal(SIGTERM, 'handleSignal');
37pcntl_signal(SIGINT, 'handleSignal');
38
39echo 'received ';
40
41$duration = isset($argv[1]) ? (int) $argv[1] : 3;
42$start = microtime(true);
43
44while ($duration > (microtime(true) - $start)) {
45 usleep(10000);
46 pcntl_signal_dispatch();
47}
handleSignal($signal)
An exception for terminatinating execution or to throw for unit testing.
$argv