wordpress-website-lifecycle/debug/debug-infinite-loop.php
Viktor Szépe 74ea3f4436
Some checks failed
Back-end / Syntax errors (push) Has been cancelled
Integrity / Integrity (push) Has been cancelled
Spelling / 文A Typos check (push) Has been cancelled
Create debug-infinite-loop.php for loop detection
Added a PHP script to handle infinite loop detection using signals.
2026-02-04 20:32:43 +01:00

21 lines
542 B
PHP

<?php
/*
* Insert this snippet in wp-config
* and watch error.log
*/
if (function_exists('pcntl_async_signals')) {
pcntl_async_signals(true);
}
if (function_exists('pcntl_signal') && function_exists('pcntl_alarm')) {
pcntl_signal(SIGALRM, function () {
error_log("\n\n=== WATCHDOG TIMEOUT ===\n");
error_log(print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 60), true));
exit(124);
});
// Trigger after this many seconds
pcntl_alarm(4);
} else {
error_log("pcntl_* not available\n");
}