This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write




Looking at the appended bug report, I guess we should check for
if (fp->_flags & _IO_NO_WRITES)

in the fread implementation.  But what's the right place and who
exactly should we change it?

Could somebody also verify that the reverse situation (writing to a
file that is read only) is handled correctly?

Btw. I checked this with glibc 2.1.2pre1.

Thanks,
Andreas



Topics:
   ferror() after fread() on a FILE* opened for write


----------------------------------------------------------------------

Date: Tue, 20 Jul 1999 19:41:05 -0700
From: Gurusamy Sarathy <gsar@activestate.com>
To: bug-glibc@gnu.org
cc: gsar@activestate.com
Subject: ferror() after fread() on a FILE* opened for write
Message-Id: <199907210241.TAA27866@activestate.com>

The following little program:

    #include <stdio.h>
    int
    main(int argc, char **argv)
    {
	char buf;
	int r = fread(&buf,1,1,stdout);
	printf("%d ferror=%d feof=%d\n", r, ferror(stdout), feof(stdout));
	return 0;
    }

prints:

    0 ferror=0 feof=0

The result is unchanged if I replace stdout with the result of, say,
fopen("/tmp/foo","w").

On a stock Debian 2.1 system with libc-2.0.7.so, this causes one of the
tests in the upcoming Perl development release to fail.  I'm inclined to
think it is a glibc bug.

FWIW, ferror() returns non-zero in the above on all other platforms
I've tried.


Sarathy
gsar@activestate.com


------------------------------

End of forwardBcAUri Digest
***************************



-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]