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 --- php-5.2.5RC2/sapi/cgi/cgi_main.c 2007-11-01 17:23:14.000000000 +0200
21 +++ php-5.2.5RC2-graceful/sapi/cgi/cgi_main.c 2007-11-08 00:46:38.999355875 +0200
24 static int parent = 1;
27 +/* Socket we are listening on incoming FastCGI connections */
28 +static int fcgi_fd = 0;
34 @@ -1157,6 +1162,22 @@
40 + * Graceful shutdown. Close listening sockets.
42 +void fastcgi_graceful_shutdown(int signal)
45 + fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
48 + /* Close the listening socket so new processes can reuse the same port */
49 + closesocket(fcgi_fd);
55 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
56 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
59 int fastcgi = fcgi_is_fastcgi();
60 char *bindpath = NULL;
65 @@ -1538,9 +1558,17 @@
68 /* don't catch our signals */
69 - sigaction(SIGTERM, &old_term, 0);
70 sigaction(SIGQUIT, &old_quit, 0);
71 sigaction(SIGINT, &old_int, 0);
74 + /* call graceful shutdown handler for SIGTERM */
76 + act.sa_handler = fastcgi_graceful_shutdown;
77 + sigaction(SIGTERM, &act, &old_term);
79 + sigaction(SIGTERM, &old_term, 0);
83 perror("php (pre-forking)");