From: [EMAIL PROTECTED] Operating system: Linux PHP version: 4.2.3 PHP Bug Type: Sockets related Bug description: socket_accept() in blocking mode doesn't handle signal interrupts
The socket_accept() function doesn't appear to handle kernel level system interrupts. This is a problem because PHP scripts written to use pcntl_signal() won't be executed while socket_accept() is in blocking mode. THAT is a problem because the script can't be killed with: kill -s SIGUSR1 [pid] and can't reap zombie processes when SIGCHLD is given (not that is much of a problem on Linux, since you can use SIG_IGN). A workaround I've made is to set a socket to non-blocking mode: socket_set_nonblock($hSocket); And then use a while loop like so: while (($hClient = @socket_accept($hSocket)) === false) { // If this is a real error, we need to handle it. Unfortunately, in this // event we just die() essentially. if (!is_resource($hSocket)) { error_log(socket_strerror(socket_last_error($hSocket))); exit; } // We need to sleep for one second so that CPU isn't absorbed with this // process. This may seem clunky, but select() doesn't appear to work // correctly with accept() in PHP in blocking mode (that is EINTR does // not appear to work correctly), thus preventing signals from being // received. This, in effect, makes the process unkillable. This is the // workaround, for the moment. sleep(1); } While this works, it would be much better if it just returned when a system interrupt is given like the C-equivalent does. This works because the system can't receive messages from the kernel because it isn't blocking. -- Edit bug report at http://bugs.php.net/?id=20745&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20745&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20745&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20745&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20745&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20745&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20745&r=support Expected behavior: http://bugs.php.net/fix.php?id=20745&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20745&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20745&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20745&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20745&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20745&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20745&r=isapi