lbarnaud Tue Apr 7 16:11:58 2009 UTC
Modified files: (Branch: PHP_5_2)
/php-src/sapi/cli php_cli.c
/php-src NEWS
Log:
MFH: Fixed bug #47893 (CLI aborts on non blocking stdout)
http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.129.2.13.2.30&r2=1.129.2.13.2.31&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.129.2.13.2.30
php-src/sapi/cli/php_cli.c:1.129.2.13.2.31
--- php-src/sapi/cli/php_cli.c:1.129.2.13.2.30 Wed Dec 31 11:17:49 2008
+++ php-src/sapi/cli/php_cli.c Tue Apr 7 16:11:57 2009
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli.c,v 1.129.2.13.2.30 2008/12/31 11:17:49 sebastian Exp $ */
+/* $Id: php_cli.c,v 1.129.2.13.2.31 2009/04/07 16:11:57 lbarnaud Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -91,6 +91,12 @@
#include "php_getopt.h"
+#ifndef PHP_WIN32
+# define php_select(m, r, w, e, t) select(m, r, w, e, t)
+#else
+# include "win32/select.h"
+#endif
+
PHPAPI extern char *php_ini_opened_path;
PHPAPI extern char *php_ini_scanned_files;
@@ -224,15 +230,38 @@
#define STDOUT_FILENO 1
#endif
+static inline int sapi_cli_select(int fd)
+{
+ fd_set wfd, dfd;
+ struct timeval tv;
+ int ret;
+
+ FD_ZERO(&wfd);
+ FD_ZERO(&dfd);
+
+ PHP_SAFE_FD_SET(fd, &wfd);
+
+ tv.tv_sec = FG(default_socket_timeout);
+ tv.tv_usec = 0;
+
+ ret = php_select(fd+1, &dfd, &wfd, &dfd, &tv);
+
+ return ret != -1;
+}
+
static inline size_t sapi_cli_single_write(const char *str, uint str_length)
/* {{{ */
{
#ifdef PHP_WRITE_STDOUT
long ret;
- ret = write(STDOUT_FILENO, str, str_length);
+ do {
+ ret = write(STDOUT_FILENO, str, str_length);
+ } while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO));
+
if (ret <= 0) {
return 0;
}
+
return ret;
#else
size_t ret;
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1463&r2=1.2027.2.547.2.1464&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1463 php-src/NEWS:1.2027.2.547.2.1464
--- php-src/NEWS:1.2027.2.547.2.1463 Tue Apr 7 15:34:37 2009
+++ php-src/NEWS Tue Apr 7 16:11:57 2009
@@ -11,6 +11,7 @@
- Fixed segfault on invalid session.save_path. (Hannes)
- Fixed bug #47903 ("@" operator does not work with string offsets). (Felipe)
+- Fixed bug #47893 (CLI aborts on non blocking stdout). (Arnaud)
- Fixed bug #47849 (Non-deep import loses the namespace). (Rob)
- Fixed bug #47845 (PDO_Firebird omits first row from query). (Lars W)
- Fixed bug #47831 (Compile warning for strnlen() in main/spprintf.c).
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php