Bug#346437: dietlibc-dev: fflush(NULL) flushes input-only streams (stdin)
Gerrit Pape <[EMAIL PROTECTED]> wrote: > On Sat, Jan 07, 2006 at 03:33:43PM -0800, Eric Wong wrote: > > fflush(NULL) seems to flush the stdin stream, as well as any open > > streams it can find, regardless of whether or not it's a writeable > > stream. According to the fflush manpage, this is wrong: > > > > If the stream argument is NULL, fflush() flushes all open > > output streams. > > > > You can see this behavior with the test program I've included below, and > > then test it again by commenting out the fflush(NULL) call in it to see > > the difference. > > Hi Eric, while I can see from the dietlibc sources that indeed the input > streams including stdin are fflushed, I currently cannot see the impact. > > Can you please show me how to use your test program to see a difference? Just use it to read a text file from stdin. You'll note that there are missing lines when compiled with dietlibc > > #include > > #include > > > > int main (void) > > { > > char buf[4096]; > > while (fgets(buf,4096,stdin)) { > > /* this can also be fwrite/fprintf: */ > > write(1,buf,strlen(buf)); > > > > /* you can comment this out to compare */ > > fflush(NULL); > > } > > > > return 0; > > } > > > > /* EOF */ > -- Eric Wong signature.asc Description: Digital signature
Bug#346437: dietlibc-dev: fflush(NULL) flushes input-only streams (stdin)
On Sat, Jan 07, 2006 at 03:33:43PM -0800, Eric Wong wrote: > fflush(NULL) seems to flush the stdin stream, as well as any open > streams it can find, regardless of whether or not it's a writeable > stream. According to the fflush manpage, this is wrong: > > If the stream argument is NULL, fflush() flushes all open > output streams. > > You can see this behavior with the test program I've included below, and > then test it again by commenting out the fflush(NULL) call in it to see > the difference. Hi Eric, while I can see from the dietlibc sources that indeed the input streams including stdin are fflushed, I currently cannot see the impact. Can you please show me how to use your test program to see a difference? Thanks, Gerrit. > #include > #include > > int main (void) > { > char buf[4096]; > while (fgets(buf,4096,stdin)) { > /* this can also be fwrite/fprintf: */ > write(1,buf,strlen(buf)); > > /* you can comment this out to compare */ > fflush(NULL); > } > > return 0; > } > > /* EOF */ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Bug#346437: dietlibc-dev: fflush(NULL) flushes input-only streams (stdin)
Package: dietlibc-dev Version: 0.29-8 Severity: normal fflush(NULL) seems to flush the stdin stream, as well as any open streams it can find, regardless of whether or not it's a writeable stream. According to the fflush manpage, this is wrong: If the stream argument is NULL, fflush() flushes all open output streams. You can see this behavior with the test program I've included below, and then test it again by commenting out the fflush(NULL) call in it to see the difference. #include #include int main (void) { char buf[4096]; while (fgets(buf,4096,stdin)) { /* this can also be fwrite/fprintf: */ write(1,buf,strlen(buf)); /* you can comment this out to compare */ fflush(NULL); } return 0; } /* EOF */ -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.14.2-g54f4bf28 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) dietlibc-dev depends on no packages. Versions of packages dietlibc-dev recommends: pn dietlibc (no description available) -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]