diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 1e31934f1581c..008d01b0aa416 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -407,7 +407,6 @@ void shutdown_executor(void) /* {{{ */ zend_shutdown_executor_values(fast_shutdown); zend_weakrefs_shutdown(); - zend_max_execution_timer_shutdown(); zend_fiber_shutdown(); zend_try { diff --git a/Zend/zend_max_execution_timer.c b/Zend/zend_max_execution_timer.c index b1c83e9cbb3a6..3c07ea7908104 100644 --- a/Zend/zend_max_execution_timer.c +++ b/Zend/zend_max_execution_timer.c @@ -35,18 +35,25 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */ { + pid_t pid = getpid(); + + if (EG(pid) == pid) { + return; + } + struct sigevent sev; sev.sigev_notify = SIGEV_THREAD_ID; sev.sigev_value.sival_ptr = &EG(max_execution_timer_timer); sev.sigev_signo = SIGRTMIN; sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid); - EG(pid) = getpid(); // Measure wall time instead of CPU time as originally planned now that it is possible https://github.com/php/php-src/pull/6504#issuecomment-1370303727 if (timer_create(CLOCK_BOOTTIME, &sev, &EG(max_execution_timer_timer)) != 0) { zend_strerror_noreturn(E_ERROR, errno, "Could not create timer"); } + EG(pid) = pid; + # ifdef MAX_EXECUTION_TIMERS_DEBUG fprintf(stderr, "Timer %#jx created on thread %d\n", (uintmax_t) EG(max_execution_timer_timer), sev.sigev_notify_thread_id); # endif