MDL-84446 core: Check existence of pcntl_signal

This commit is contained in:
Andrew Nicols 2025-02-18 06:19:38 +08:00
parent 3c848c4dce
commit c89067d1b8
No known key found for this signature in database
GPG key ID: 6D1E3157C8CFBF14

View file

@ -56,13 +56,17 @@ class core_shutdown_manager {
// 'pcntl_async_signals' // 'pcntl_async_signals'
// 'pcntl_signal' // 'pcntl_signal'
// The 'pcntl' extension is optional and not available on Windows. // The 'pcntl' extension is optional and not available on Windows.
if (extension_loaded('pcntl') && function_exists('pcntl_async_signals')) { if (extension_loaded('pcntl')) {
if (function_exists('pcntl_async_signals')) {
// We capture and handle SIGINT (Ctrl+C) and SIGTERM (termination requested). // We capture and handle SIGINT (Ctrl+C) and SIGTERM (termination requested).
pcntl_async_signals(true); pcntl_async_signals(true);
}
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGINT, ['core_shutdown_manager', 'signal_handler']); pcntl_signal(SIGINT, ['core_shutdown_manager', 'signal_handler']);
pcntl_signal(SIGTERM, ['core_shutdown_manager', 'signal_handler']); pcntl_signal(SIGTERM, ['core_shutdown_manager', 'signal_handler']);
} }
} }
}
/** /**
* Signal handler for SIGINT, and SIGTERM. * Signal handler for SIGINT, and SIGTERM.