3 http://bugs.php.net/bug.php?id=41593
4 http://bugs.php.net/bug.php?id=36158
5 http://bugs.php.net/bug.php?id=43224
6 http://php-fpm.anight.org/
10 echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
13 echo (++$i), "<br>\n";
20 diff -urNp -x '*.orig' php-5.2.17.org/sapi/cgi/cgi_main.c php-5.2.17/sapi/cgi/cgi_main.c
21 --- php-5.2.17.org/sapi/cgi/cgi_main.c 2021-10-23 19:05:04.013125101 +0200
22 +++ php-5.2.17/sapi/cgi/cgi_main.c 2021-10-23 19:05:06.359791768 +0200
23 @@ -100,6 +100,11 @@ static void (*php_php_import_environment
25 static int children = 0;
28 +/* Socket we are listening on incoming FastCGI connections */
29 +static int fcgi_fd = 0;
33 * Set to non-zero if we are the parent process
35 @@ -1225,6 +1230,22 @@ void fastcgi_cleanup(int signal)
41 + * Graceful shutdown. Close listening sockets.
43 +void fastcgi_graceful_shutdown(int signal)
46 + fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
49 + /* Close the listening socket so new processes can reuse the same port */
50 + closesocket(fcgi_fd);
56 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
57 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
58 @@ -1343,7 +1364,6 @@ int main(int argc, char *argv[])
60 int fastcgi = fcgi_is_fastcgi();
61 char *bindpath = NULL;
66 @@ -1632,9 +1652,17 @@ consult the installation file that came
69 /* don't catch our signals */
70 - sigaction(SIGTERM, &old_term, 0);
71 sigaction(SIGQUIT, &old_quit, 0);
72 sigaction(SIGINT, &old_int, 0);
75 + /* call graceful shutdown handler for SIGTERM */
77 + act.sa_handler = fastcgi_graceful_shutdown;
78 + sigaction(SIGTERM, &act, &old_term);
80 + sigaction(SIGTERM, &old_term, 0);
84 perror("php (pre-forking)");