3 http://bugs.php.net/bug.php?id=43224 this patch
5 http://bugs.php.net/bug.php?id=41593
6 http://bugs.php.net/bug.php?id=36158
7 http://php-fpm.anight.org/
11 echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
14 echo (++$i), "<br>\n";
21 diff -urNp -x '*.orig' php-7.2.34.org/sapi/cgi/cgi_main.c php-7.2.34/sapi/cgi/cgi_main.c
22 --- php-7.2.34.org/sapi/cgi/cgi_main.c 2020-09-30 07:15:50.000000000 +0200
23 +++ php-7.2.34/sapi/cgi/cgi_main.c 2021-08-24 01:07:35.169922301 +0200
24 @@ -114,6 +114,9 @@ static void (*php_php_import_environment
25 static int children = 0;
28 +/* Socket we are listening on incoming connections */
29 +static int fcgi_fd = 0;
32 * Set to non-zero if we are the parent process
34 @@ -1521,6 +1524,21 @@ BOOL WINAPI fastcgi_cleanup(DWORD sig)
39 + * Graceful shutdown. Close listening sockets.
41 +void fastcgi_graceful_shutdown(int signal)
44 + fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
47 + /* Close the listening socket so new processes can reuse the same port */
48 + closesocket(fcgi_fd);
54 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
55 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
56 @@ -1816,7 +1834,6 @@ int main(int argc, char *argv[])
59 char *bindpath = NULL;
61 fcgi_request *request = NULL;
62 int warmup_repeats = 0;
64 @@ -2129,9 +2146,14 @@ consult the installation file that came
67 /* don't catch our signals */
68 - sigaction(SIGTERM, &old_term, 0);
69 sigaction(SIGQUIT, &old_quit, 0);
70 sigaction(SIGINT, &old_int, 0);
72 + /* call graceful shutdown handler for SIGTERM */
74 + act.sa_handler = fastcgi_graceful_shutdown;
75 + sigaction(SIGTERM, &act, &old_term);