From: [EMAIL PROTECTED] Operating system: SuSE 7.0 Kernel 2.2.17 PHP version: 4.1.1 PHP Bug Type: Unknown/Other Function Bug description: pcntl_signal() does not work while waiting with socket_accept()
Configure Command: ./configure --with-imap --with-mysql --enable-sockets --enable-pcntl Example: #! /usr/local/bin/php -q <?php error_reporting(E_ALL); set_time_limit(0); function sig_handler($signo) { switch($signo) { case SIGTERM: // handle shutdown tasks echo "Got SIGTERM! Closing sockets and exiting...\n"; @socket_close($msgsock); @socket_close($sock); exit; break; case SIGINT: // handle shutdown tasks echo "Got SIGINT! Closing sockets and exiting...\n"; @socket_close($msgsock); @socket_close($sock); exit; break; default: // handle all other signals } } $address = "127.0.0.1"; $port = 5550; echo "Installing signal handler...\n"; if (pcntl_signal(SIGTERM, "sig_handler")) echo "SIGTERM installed!\n"; if (pcntl_signal(SIGINT, "sig_handler")) echo "SIGINT installed!\n"; if (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) < 0) { echo "socket_create() failed: reason: " . strerror($sock) . "\n"; exit; } if (($ret = socket_bind($sock, $address, $port)) < 0) { echo "socket_bind() failed: reason: " . strerror($ret) . "\n"; exit; } if (($ret = socket_listen($sock, 5)) < 0) { echo "socket_listen() failed: reason: " . strerror($ret) . "\n"; exit; } do { echo "Listening...\n"; if (($msgsock = socket_accept($sock)) < 0) { echo "socket_accept() failed: reason: " . strerror($msgsock) . "\n"; break; } else { socket_write($msgsock, "READY\n", 6); } do { break 1; } while(true); socket_close($msgsock); } while(true); socket_close($sock); ---END--- This peace of code is waiting for a socket connection with socket_accept() and has installed signal handlers for SIGINT and SIGTERM! I'm expecting that catching signal SIGINT should enter the function sig_handler() even if the script is waiting for a connection at this moment. That does not happen, any signal installed with pcntl_signal() is ignored (of course not SIGKIL) while waiting for connections with socket_accept(). The script does not enter the function sig_handler(). Kind regards Chris -- Edit bug report at http://bugs.php.net/?id=15906&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=15906&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=15906&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=15906&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=15906&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=15906&r=support Expected behavior: http://bugs.php.net/fix.php?id=15906&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=15906&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=15906&r=submittedtwice