<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Runs a PHP script that can be stopped only with a SIGKILL (9) signal for 3 seconds. * * @args duration Run this script with a custom duration * * @example `php NonStopableProcess.php 42` will run the script for 42 seconds */ function handleSignal($signal) { $name = match ($signal) { \SIGTERM => 'SIGTERM', \SIGINT => 'SIGINT', default => $signal.' (unknown)', }; echo "signal $name\n"; } pcntl_signal(\SIGTERM, 'handleSignal'); pcntl_signal(\SIGINT, 'handleSignal'); echo 'received '; $duration = isset($argv[1]) ? (int) $argv[1] : 3; $start = microtime(true); while ($duration > (microtime(true) - $start)) { usleep(10000); pcntl_signal_dispatch(); }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
CreateNewConsoleTest.php | File | 1.37 KB | 0644 |
|
ErrorProcessInitiator.php | File | 955 B | 0644 |
|
ExecutableFinderTest.php | File | 4.77 KB | 0644 |
|
KillableProcessWithOutput.php | File | 537 B | 0644 |
|
NonStopableProcess.php | File | 993 B | 0644 |
|
PhpExecutableFinderTest.php | File | 2.6 KB | 0644 |
|
PhpProcessTest.php | File | 2.28 KB | 0644 |
|
PipeStdinInStdoutStdErrStreamSelect.php | File | 1.77 KB | 0644 |
|
ProcessFailedExceptionTest.php | File | 4.69 KB | 0644 |
|
ProcessTest.php | File | 49.27 KB | 0644 |
|
SignalListener.php | File | 420 B | 0644 |
|
ThreeSecondProcess.php | File | 305 B | 0644 |
|