#49819 [Opn]: STDOUT losing data with posix_isatty()

2009-10-11 Thread Sjoerd
 ID:  49819
 Updated by:  sjo...@php.net
 Reported By: cschneid at cschneid dot com
 Status:  Open
 Bug Type:Streams related
 PHP Version: 6SVN-2009-10-09 (SVN)
 New Comment:

Could reproduce with PHP 5.3-HEAD.


Previous Comments:


[2009-10-09 12:54:53] cschneid at cschneid dot com

--- sapi/cli/php_cli.c  (revision 289412)
+++ sapi/cli/php_cli.c  (working copy)
@@ -565,6 +565,10 @@
s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
 #endif

+   s_in->flags  |= PHP_STREAM_FLAG_NO_SEEK;
+   s_out->flags |= PHP_STREAM_FLAG_NO_SEEK;
+   s_err->flags |= PHP_STREAM_FLAG_NO_SEEK;
+
s_in_process = s_in;

php_stream_to_zval(s_in,  zin);



[2009-10-09 12:50:19] cschneid at cschneid dot com

Description:

The PHP streams for stdin, stdout and stderr are seekable which results
in php_stream_flush() and seek being called on it.

For some reason php_stream_flush() fails to actually write the data
while still calling seek and resetting the stream position.

Suggested solution:
- Find out why php_stream_flush() fails and fix it (I don't know enough
about it)
- Mark (some? all?) stdio streams as PHP_STREAM_FLAG_NO_SEEK in
sapi/cli/php_cli.c (see patch)
- Mark stdio streams as PHP_STREAM_FLAG_NO_SEEK in
ext/standard/php_fopen_wrapper.c


Reproduce code:
---
php -r 'echo "hello1\n"; posix_isatty(STDOUT); echo "hello2\n";' >out;
cat out


Expected result:

hello1
hello2


Actual result:
--
hello2






-- 
Edit this bug report at http://bugs.php.net/?id=49819&edit=1



#49819 [Opn]: STDOUT losing data with posix_isatty()

2009-10-09 Thread cschneid at cschneid dot com
 ID:  49819
 User updated by: cschneid at cschneid dot com
 Reported By: cschneid at cschneid dot com
 Status:  Open
 Bug Type:Streams related
 PHP Version: 6SVN-2009-10-09 (SVN)
 New Comment:

--- sapi/cli/php_cli.c  (revision 289412)
+++ sapi/cli/php_cli.c  (working copy)
@@ -565,6 +565,10 @@
s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
 #endif

+   s_in->flags  |= PHP_STREAM_FLAG_NO_SEEK;
+   s_out->flags |= PHP_STREAM_FLAG_NO_SEEK;
+   s_err->flags |= PHP_STREAM_FLAG_NO_SEEK;
+
s_in_process = s_in;

php_stream_to_zval(s_in,  zin);


Previous Comments:


[2009-10-09 12:50:19] cschneid at cschneid dot com

Description:

The PHP streams for stdin, stdout and stderr are seekable which results
in php_stream_flush() and seek being called on it.

For some reason php_stream_flush() fails to actually write the data
while still calling seek and resetting the stream position.

Suggested solution:
- Find out why php_stream_flush() fails and fix it (I don't know enough
about it)
- Mark (some? all?) stdio streams as PHP_STREAM_FLAG_NO_SEEK in
sapi/cli/php_cli.c (see patch)
- Mark stdio streams as PHP_STREAM_FLAG_NO_SEEK in
ext/standard/php_fopen_wrapper.c


Reproduce code:
---
php -r 'echo "hello1\n"; posix_isatty(STDOUT); echo "hello2\n";' >out;
cat out


Expected result:

hello1
hello2


Actual result:
--
hello2






-- 
Edit this bug report at http://bugs.php.net/?id=49819&edit=1