File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,6 +162,10 @@ static void frankenphp_fork_child(void) {
162162 pthread_detach (watcher );
163163#endif
164164}
165+
166+ static void frankenphp_register_atfork (void ) {
167+ pthread_atfork (frankenphp_fork_prepare , NULL , frankenphp_fork_child );
168+ }
165169#endif
166170
167171/* Best-effort force-kill for stuck PHP threads.
@@ -927,8 +931,10 @@ static const zend_function_entry frankenphp_test_hook_functions[] = {
927931
928932PHP_MINIT_FUNCTION (frankenphp ) {
929933 register_frankenphp_symbols (module_number );
930- #ifndef
931- pthread_atfork (frankenphp_fork_prepare , NULL , frankenphp_fork_child );
934+ #ifndef PHP_WIN32
935+ /* MINIT runs once per ZTS thread — guard the atfork registration */
936+ static pthread_once_t atfork_once = PTHREAD_ONCE_INIT ;
937+ pthread_once (& atfork_once , frankenphp_register_atfork );
932938#endif
933939
934940#ifdef FRANKENPHP_TEST
You can’t perform that action at this time.
0 commit comments