Re: Write to a closed stream bug.

Alan Cox (alan@lxorguk.ukuu.org.uk)
Wed, 17 Dec 1997 23:55:11 +0000 (GMT)


> The glibc bug is that a write to a closed file descriptor does not
> return an error.

This is correct behaviour

> allow this behavior, the standards are wrong. No 'C' runtime library
> that I have checked during the past two weeks has allowed this behavior.

Its also a performance and scaling issue.

> be performed. It is entirely unacceptable for any function, whether
> it is in a runtime-library, or is coded by an application, to
> pretend that it performed some function that, in fact, it did not.

try strcpy(0x12543456, 0x247375394)

shock horror it crashes. You passed it a bad pointer. You did the same
to the fwrite after fclose. That standard, sensibly, does not define what
happens when you feed it stupid random pointers.

File handles are strictly defined, and a write() to a closed file handle returns
-EBADF.

Alan