ID:               41593
 Comment by:       stephan dot jaeger at ewetel dot de
 Reported By:      jonepet at dcvhost dot no
 Status:           No Feedback
 Bug Type:         CGI related
 Operating System: Linux
 PHP Version:      5.2.3
 Assigned To:      dmitry
 New Comment:

The mod_fastcgi patch above works with PHP5 (5.2.3 here). But PHP 4
does not have a signal handler for SIGTERM, so it exits immediatly
without finishing the current request and still gives a 500. Adding a
signal handler for SIGTERM seems to solve this problem:

--- os_unix.c.orig      2008-06-02 11:29:25.000000000 +0200
+++ os_unix.c   2008-06-02 11:29:46.000000000 +0200
@@ -147,6 +147,7 @@
 
     sa.sa_handler = OS_Sigusr1Handler;
     installSignalHandler(SIGUSR1, &sa, force);
+    installSignalHandler(SIGTERM, &sa, force);
 }
 
 /*


Previous Comments:
------------------------------------------------------------------------

[2008-04-06 15:39:27] hanno at hboeck dot de

Bernd Wurst has written a workaround-patch for fastcgi, which can be
found here:
http://svn.schokokeks.org/repos/overlay/trunk/www-apache/mod_fastcgi/files/fcgi_pm.c.diff

Maybe some more skilled programmers want to comment on it.

------------------------------------------------------------------------

[2008-03-24 11:41:27] void at voip dot e-burg dot ru

PHP 5.2.6RC1
i run php-cgi directly from initng and have term_timeout = 80,
ei initng suspends SIGKILL for 80sec after SIGTERM

when i sigterm php-cgi, i get this fom my web server (lighttpd):
 (mod_fastcgi.c.2462) unexpected end-of-file (perhaps the fastcgi
process died): pid: 0 socket: tcp:172.31.2.108:1026
 (mod_fastcgi.c.3254) response not received, request sent: 1538 on
socket: tcp:172.31.2.108:1026 for /index.php , closing connection

it seems php even not try to shutdown gracefuly

------------------------------------------------------------------------

[2008-02-27 22:29:22] dan at sypher7 dot com

I previously reported that this issue was only effecting PHP4 and not
PHP5. I've now seen PHP 5.2.5 throw 500 errors as well (using
mod_fastcgi).

I believe there are actually two different bugs here. One of them is
with PHP 4.4.8. That bug is that fastcgi mode PHP does not clean up and
exit properly (send headers, etc.) on a SIGTERM from the fastcgi process
manager. It simply dies and returns no headers resulting in the 500
error in Apache. This is incorrect cleanup on the part of PHP.

Doing some further digging, there appear to be indications that the
fastcgi process manager will send a SIGKILL after a SIGTERM if the
process doesn't finish sufficiently fast. Although I did see comments
indicating this in the mod_fastcgi code, and corresponding code that
would do that on Win32 platforms, I could not find in the source code
that mod_fastcgi's process manager would actually do this for a *nix
platform, so I'm unsure if this is actually happening.

In any case, the problem with PHP5 throwing the 500 errors seems to be
that it is getting a SIGKILL from someone (either Apache or
mod_fastcgi), which isn't really a PHP bug, but something to be looked
into with either apache or the fastcgi people. I'm investigating that,
but the issues with PHP4 still stand.

------------------------------------------------------------------------

[2008-02-26 08:48:08] marekm at apnet dot pl

I can confirm that the same problem happens with Apache 2.2.8 +
mod_fastcgi 2.4.6 + PHP 5.2.5 ie. graceful restarts always cause error
500. This is absolutely repeatable.

------------------------------------------------------------------------

[2008-02-18 19:13:22] dan at sypher7 dot com

I just wanted to follow up:

I recently installed PHP 5.2.5 alongside 4.4.8. With the identical
setup. PHP4 will cause the internal server error, but PHP5 will not. So
this appears to be a PHP4-only issue.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/41593

-- 
Edit this bug report at http://bugs.php.net/?id=41593&edit=1

Reply via email to