Problem with line buffering and getc function on 1.7.33.

Kaz Kylheku 920-082-4242@kylheku.com
Fri Mar 11 19:17:00 GMT 2016


Hi all,

On a Cygwin installation version 1.7.33-2(0.280/5/3), I encountered an 
odd issue.

I wrote it up in a StackOverflow question:

http://stackoverflow.com/questions/35928828/cygwin-missing-stream-data-due-to-stdio-putc-line-buffering

This contains a repro test case.

For the benefit of non-users of WWW, the summary is this:
I'm sending data to a stdio stream which has been fdopen-ed from a 
socket
descriptor (which could be irrelevant). The stream is put into line
buffered mode with setvbuf.  When the getc function is used to perform
output on this stream, it loses data. When the string "REPLY\n" is sent,
character by character, the receiver receives only "\n".

If line buffering is not employed, or of putc(ch, stream) is replaced
by fputs(str, stream) (where str is a one-character-long string 
containing
the character to be output), then things work as expected.

Here is a patch I put into the real program where this issue was
found:

http://www.kylheku.com/cgit/txr/commit/?id=3c5f110cc29f8d3fbf2069c68d25ccebee46679e

with the patch, TXR's socket test cases pass on Cygwin.
The tests pass on Solaris 10, various GNU/Linuxes and Mac OS 10.7.3.




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list