PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / symfony / process / Tests / NonStopableProcess.php

NonStopableProcess.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/symfony/process/Tests/NonStopableProcess.php

48 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 /**
13 * Runs a PHP script that can be stopped only with a SIGKILL (9) signal for 3 seconds.
14 *
15 * @args duration Run this script with a custom duration
16 *
17 * @example `php NonStopableProcess.php 42` will run the script for 42 seconds
18 */
19 function 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
36 pcntl_signal(\SIGTERM, 'handleSignal');
37 pcntl_signal(\SIGINT, 'handleSignal');
38
39 echo 'received ';
40
41 $duration = isset($argv[1]) ? (int) $argv[1] : 3;
42 $start = microtime(true);
43
44 while ($duration > (microtime(true) - $start)) {
45 usleep(10000);
46 pcntl_signal_dispatch();
47 }
48