This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/712] New: fread() should not call read() again once the latter returns zero
- From: "bww at acm dot org" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 10 Feb 2005 21:02:19 -0000
- Subject: [Bug libc/712] New: fread() should not call read() again once the latter returns zero
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
/*
* fread() should not call read() again once the latter
* returns zero, otherwise the following "cat" program
* requires two EOF indications to terminate (which has
* the most obvious effect when reading from a terminal).
*
* For example under Fedora Core release 3 ...
* % gcc -static c.c -o c
* % echo hello | strace -e read ./c
* read(0, "hello\n", 4096) = 6
* read(0, "", 4096) = 0
* hello
* read(0, "", 4096) = 0
*
* whereas under Solaris 5.8 ...
* % gcc -static c.c -o c
* % echo hello | truss -t read ./c
* read(0, " h e l l o\n", 5120) = 6
* read(0, 0x000549DC, 5120) = 0
* hello
*/
#include <stdio.h>
int
main()
{
char buf[128];
size_t cc;
while ((cc = fread(buf, 1, sizeof buf, stdin)) != 0)
fwrite(buf, 1, cc, stdout);
return 0;
}
--
Summary: fread() should not call read() again once the latter
returns zero
Product: glibc
Version: 2.3.4
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: bww at acm dot org
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=712
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.