1 --- php-4.4.7/sapi/cgi/cgi_main.c 2007-02-16 13:47:20.000000000 +0200
2 +++ php-4.4.7-gracefup/sapi/cgi/cgi_main.c 2007-11-09 17:19:32.722741559 +0200
8 +/* Socket we are listening on incoming FastCGI connections */
9 +static int fcgi_fd = 0;
21 + * Graceful shutdown. Close listening sockets.
23 +void fastcgi_graceful_shutdown(int signal)
26 + fprintf(stderr, "FastCGI graceful shutdown, pid %d\n", getpid());
29 + /* Close the listening socket so new processes can reuse the same port */
30 + closesocket(fcgi_fd);
37 int main(int argc, char *argv[])
40 char *bindpath = NULL;
46 @@ -1238,9 +1258,17 @@
49 /* don't catch our signals */
50 - sigaction( SIGTERM, &old_term, 0 );
51 sigaction( SIGQUIT, &old_quit, 0 );
52 sigaction( SIGINT, &old_int, 0 );
55 + /* call graceful shutdown handler for SIGTERM */
57 + act.sa_handler = fastcgi_graceful_shutdown;
58 + sigaction(SIGTERM, &act, &old_term);
60 + sigaction(SIGTERM, &old_term, 0);
64 perror( "php (pre-forking)" );