ID: 20745 Comment by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: No Feedback Bug Type: Sockets related Operating System: Linux PHP Version: 4.2.3 New Comment:
I'd like to revive this bug .. as of 4.3.0 this beheaviour persists .. I even tried this define(ticks=1); approach quoted in one of the related bugs .. it didnt help .. during a call to socket_accept() as far as I can see (I've tested only with SIGTERM and SIGINT) .. those handlers never get called .. with the new feature (the 3rd param on pcntl_signal() .. set to false) .. the socket_accept() call gets interrupted, but the handler is still not called. I would say there is a need to resolve this .. right now there is no way to cleanly kill a daemon process running php unless non blocking sockets are used .. which is basicaly a waste of cpu cycles .. Please respond as to the status of this problem asap. Previous Comments: ------------------------------------------------------------------------ [2002-12-15 04:05:02] [EMAIL PROTECTED] No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. ------------------------------------------------------------------------ [2002-12-01 14:31:23] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-latest.zip ------------------------------------------------------------------------ [2002-12-01 07:59:34] [EMAIL PROTECTED] 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 this bug report at http://bugs.php.net/?id=20745&edit=1