3 http://bugs.php.net/bug.php?id=41593
4 http://bugs.php.net/bug.php?id=36158
5 http://php-fpm.anight.org/
9 echo php_sapi_name(), ' running ', PHP_VERSION, "<br>\n";
12 echo (++$i), "<br>\n";
19 --- php5.3-200711071330/sapi/cgi/cgi_main.c 2007-11-01 13:32:38.000000000 +0200
20 +++ php5.3-200711071330-graceful2/sapi/cgi/cgi_main.c 2007-11-07 22:12:10.025949153 +0200
23 static int parent = 1;
25 +/* Socket we are listening on incoming connections */
26 +static int fcgi_fd = 0;
31 @@ -1221,6 +1224,21 @@
36 + * Graceful shutdown. Close listening sockets.
38 +void fastcgi_graceful_shutdown(int signal)
41 + fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
44 + /* Close the listening socket so new processes can reuse the same port */
45 + closesocket(fcgi_fd);
51 STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
52 STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
55 int fastcgi = fcgi_is_fastcgi();
56 char *bindpath = NULL;
61 @@ -1579,9 +1596,13 @@
64 /* don't catch our signals */
65 - sigaction(SIGTERM, &old_term, 0);
66 - sigaction(SIGQUIT, &old_quit, 0);
67 - sigaction(SIGINT, &old_int, 0);
68 + sigaction(SIGQUIT, &act, &old_quit);
69 + sigaction(SIGINT, &act, &old_int);
71 + /* call graceful shutdown handler for SIGTERM */
73 + act.sa_handler = fastcgi_graceful_shutdown;
74 + sigaction(SIGTERM, &act, &old_term);
77 perror("php (pre-forking)");