From 1cc9346050a1e6a19d97ba7a88c722cc38e1df8e Mon Sep 17 00:00:00 2001 From: henderkes Date: Mon, 4 May 2026 12:54:56 +0700 Subject: [PATCH 1/2] extra pthread handling unlikely to be needed, but better safe than sorry --- frankenphp.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/frankenphp.c b/frankenphp.c index 8037886f67..b482f4590e 100644 --- a/frankenphp.c +++ b/frankenphp.c @@ -89,7 +89,12 @@ __thread HashTable *sandboxed_env = NULL; #ifndef PHP_WIN32 static bool is_forked_child = false; -static void frankenphp_fork_child(void) { is_forked_child = true; } +static void frankenphp_fork_child(void) { + is_forked_child = true; +#ifdef __linux__ + prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); +#endif +} #endif void frankenphp_update_local_thread_context(bool is_worker) { @@ -762,6 +767,12 @@ static int frankenphp_startup(sapi_module_struct *sapi_module) { static int frankenphp_deactivate(void) { return SUCCESS; } static size_t frankenphp_ub_write(const char *str, size_t str_length) { +#ifndef PHP_WIN32 + if (UNEXPECTED(is_forked_child)) { + return 0; + } +#endif + struct go_ub_write_return result = go_ub_write(thread_index, (char *)str, str_length); @@ -773,6 +784,12 @@ static size_t frankenphp_ub_write(const char *str, size_t str_length) { } static int frankenphp_send_headers(sapi_headers_struct *sapi_headers) { +#ifndef PHP_WIN32 + if (UNEXPECTED(is_forked_child)) { + return SAPI_HEADER_SEND_FAILED; + } +#endif + if (SG(request_info).no_headers == 1) { return SAPI_HEADER_SENT_SUCCESSFULLY; } @@ -798,6 +815,12 @@ static int frankenphp_send_headers(sapi_headers_struct *sapi_headers) { } static void frankenphp_sapi_flush(void *server_context) { +#ifndef PHP_WIN32 + if (UNEXPECTED(is_forked_child)) { + return; + } +#endif + sapi_send_headers(); if (go_sapi_flush(thread_index)) { php_handle_aborted_connection(); From 1f2963ec1945fc1ae8569d73d367a1a7d59a7c6b Mon Sep 17 00:00:00 2001 From: henderkes Date: Mon, 4 May 2026 13:06:46 +0700 Subject: [PATCH 2/2] fix ci --- .github/workflows/tests.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 396d9ccf77..144285ae18 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -56,6 +56,8 @@ jobs: env: phpts: ts debug: true + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install --reinstall -y libbrotli-dev - name: Install e-dant/watcher uses: ./.github/actions/watcher - name: Set CGO flags