[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
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 namespace Symfony\Component\Console\SignalRegistry; 13 14 final class SignalRegistry 15 { 16 private $signalHandlers = []; 17 18 public function __construct() 19 { 20 if (\function_exists('pcntl_async_signals')) { 21 pcntl_async_signals(true); 22 } 23 } 24 25 public function register(int $signal, callable $signalHandler): void 26 { 27 if (!isset($this->signalHandlers[$signal])) { 28 $previousCallback = pcntl_signal_get_handler($signal); 29 30 if (\is_callable($previousCallback)) { 31 $this->signalHandlers[$signal][] = $previousCallback; 32 } 33 } 34 35 $this->signalHandlers[$signal][] = $signalHandler; 36 37 pcntl_signal($signal, [$this, 'handle']); 38 } 39 40 public static function isSupported(): bool 41 { 42 if (!\function_exists('pcntl_signal')) { 43 return false; 44 } 45 46 if (\in_array('pcntl_signal', explode(',', ini_get('disable_functions')))) { 47 return false; 48 } 49 50 return true; 51 } 52 53 /** 54 * @internal 55 */ 56 public function handle(int $signal): void 57 { 58 $count = \count($this->signalHandlers[$signal]); 59 60 foreach ($this->signalHandlers[$signal] as $i => $signalHandler) { 61 $hasNext = $i !== $count - 1; 62 $signalHandler($signal, $hasNext); 63 } 64 } 65 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |