From: gabriel at oxeva dot fr Operating system: Linux 2.6 PHP version: 4.4.4 PHP Bug Type: CGI related Bug description: PHP fastcgi with PHP_FCGI_CHILDREN don't kill children when parent is killed
Description: ------------ Context: When running PHP in FastCGI mode with a fastCGI apache module (such a mod_fcgid), all is running fine when PHP_FCGI_CHILDREN unset : only 1 process spawned. When using PHP_FCGI_CHILDREN=n, the PHP parent process forks n childs, and the parent acts as a manager between the child processes, wait()ing to respawn them if they are killed or exit. The problem happens when the FastCGI process manager handled by the apache module has to kill the parent PHP process (it only knows the parent's PID) for any reason such as idle timeout, max lifetime, etc. Problem: While the PHP parent process is properly killed by the FastCGI process manager, the children aren't killed, but instead stay alive, waiting for a new request which will never come (because the socket shared with the parent is removed at the same time parent is killed). Reproduce code: --------------- This is not always reproducible, as the problem only happens when the php FastCGI processes are busy. The only way the kill these "orphan" children, is using the signal 9 on them (to interrupt the blocking read() syscall they are executing) Expected result: ---------------- In the example, the fastCGI process manager spawns php by fork()ing then exec()ing /path/to/php , with environment PHP_FCGI_CHILDREN=2 PHP parent process is PID 10, and it forks itself 2 childs, PID 11 and 12. When killing PID 10 with normal signal 15, and the whole php processes are under load, PID 10 is killed, but the 2 children PID 11 and 12 stay alive. The expected result is that when the PHP parent process is killed, all the children in any processing state are killed too. Actual result: -------------- strace of children processes (PID 11 and 12) still alive gives : # strace -p 11 Process 11 attached - interrupt to quit read(3, <unfinished ...> PID 12 give the same result. -- Edit bug report at http://bugs.php.net/?id=40286&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40286&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40286&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40286&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40286&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40286&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40286&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40286&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40286&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40286&r=support Expected behavior: http://bugs.php.net/fix.php?id=40286&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40286&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40286&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40286&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40286&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40286&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40286&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40286&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40286&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40286&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40286&r=mysqlcfg
