From 345a118942dcf40cc997a8792b5fbde440beff68 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 18 Feb 2025 06:19:38 +0800 Subject: [PATCH] MDL-84446 core: Check existence of pcntl_signal --- lib/classes/shutdown_manager.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/classes/shutdown_manager.php b/lib/classes/shutdown_manager.php index c36f7463f1f..bddc016fa88 100644 --- a/lib/classes/shutdown_manager.php +++ b/lib/classes/shutdown_manager.php @@ -56,11 +56,15 @@ class core_shutdown_manager { // 'pcntl_async_signals' // 'pcntl_signal' // The 'pcntl' extension is optional and not available on Windows. - if (extension_loaded('pcntl') && function_exists('pcntl_async_signals')) { - // We capture and handle SIGINT (Ctrl+C) and SIGTERM (termination requested). - pcntl_async_signals(true); - pcntl_signal(SIGINT, ['core_shutdown_manager', 'signal_handler']); - pcntl_signal(SIGTERM, ['core_shutdown_manager', 'signal_handler']); + if (extension_loaded('pcntl')) { + if (function_exists('pcntl_async_signals')) { + // We capture and handle SIGINT (Ctrl+C) and SIGTERM (termination requested). + pcntl_async_signals(true); + } + if (function_exists('pcntl_signal')) { + pcntl_signal(SIGINT, ['core_shutdown_manager', 'signal_handler']); + pcntl_signal(SIGTERM, ['core_shutdown_manager', 'signal_handler']); + } } }