Skip to content

Commit 5aff0c9

Browse files
committed
force exit after php shutdown/cleanup ran
1 parent 6b3408c commit 5aff0c9

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

frankenphp.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,12 @@ PHP_FUNCTION(frankenphp_handle_request) {
606606
}
607607
}
608608

609+
frankenphp_worker_request_shutdown();
609610
#ifndef PHP_WIN32
610611
if (is_forked_child) {
611612
_exit(0);
612613
}
613614
#endif
614-
615-
frankenphp_worker_request_shutdown();
616615
go_frankenphp_finish_worker_request(thread_index, callback_ret);
617616
if (result.r1 != NULL) {
618617
zval_ptr_dtor(result.r1);
@@ -1100,11 +1099,6 @@ static void *php_thread(void *arg) {
11001099

11011100
/* Execute the PHP script, potential bailout to zend_catch */
11021101
php_execute_script(&file_handle);
1103-
#ifndef PHP_WIN32
1104-
if (is_forked_child) {
1105-
_exit(EG(exit_status));
1106-
}
1107-
#endif
11081102
zend_destroy_file_handle(&file_handle);
11091103
reset_sandboxed_environment();
11101104

@@ -1117,16 +1111,15 @@ static void *php_thread(void *arg) {
11171111
/* shutdown the request, potential bailout to zend_catch */
11181112
php_request_shutdown((void *)0);
11191113
frankenphp_free_request_context();
1114+
#ifndef PHP_WIN32
1115+
if (is_forked_child) {
1116+
_exit(EG(exit_status));
1117+
}
1118+
#endif
11201119
go_frankenphp_after_script_execution(thread_index, EG(exit_status));
11211120
}
11221121
}
11231122
zend_catch {
1124-
#ifndef PHP_WIN32
1125-
if (is_forked_child) {
1126-
_exit(EG(exit_status));
1127-
}
1128-
#endif
1129-
11301123
/* Critical failure from php_execute_script or php_request_shutdown, mark
11311124
* the thread as unhealthy */
11321125
thread_is_healthy = false;
@@ -1146,6 +1139,11 @@ static void *php_thread(void *arg) {
11461139
PG(last_error_file) = NULL;
11471140
}
11481141
frankenphp_free_request_context();
1142+
#ifndef PHP_WIN32
1143+
if (is_forked_child) {
1144+
_exit(EG(exit_status));
1145+
}
1146+
#endif
11491147
go_frankenphp_after_script_execution(thread_index, EG(exit_status));
11501148
}
11511149
zend_end_try();

0 commit comments

Comments
 (0)