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 --- php-5.2.5RC2/sapi/cgi/cgi_main.c 2007-11-01 17:23:14.000000000 +0200
20 +++ php-5.2.5RC2-graceful/sapi/cgi/cgi_main.c 2007-11-08 00:46:38.999355875 +0200
23 static int parent = 1;
26 +/* Socket we are listening on incoming FastCGI connections */
27 +static int fcgi_fd = 0;
33 @@ -1157,6 +1162,22 @@
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)
58 int fastcgi = fcgi_is_fastcgi();
59 char *bindpath = NULL;
64 @@ -1538,9 +1558,17 @@
67 /* don't catch our signals */
68 - sigaction(SIGTERM, &old_term, 0);
69 sigaction(SIGQUIT, &old_quit, 0);
70 sigaction(SIGINT, &old_int, 0);
73 + /* call graceful shutdown handler for SIGTERM */
75 + act.sa_handler = fastcgi_graceful_shutdown;
76 + sigaction(SIGTERM, &act, &old_term);
78 + sigaction(SIGTERM, &old_term, 0);
82 perror("php (pre-forking)");