Newsgroups: comp.unix.wizards
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: checking close's return value
Message-ID: <1988Sep20.230150.7574@utzoo.uucp>
Organization: U of Toronto Zoology
References: <20981@watmath.waterloo.edu>
Date: Tue, 20 Sep 88 23:01:50 GMT

In article <20981@watmath.waterloo.edu> rbutterworth@watmath.waterloo.edu (Ray Butterworth) writes:
>[new magtape] devices use a very large buffer, and in many cases
>the tapes don't even start to move until the write-end-of-file
>command is issued by the device driver in the close.  If anything
>goes wrong and the data isn't written correctly, the close()
>function returns an error status but everything simply ignores it.
>
>If you are writing (or buying) software that is going to write
>to these devices, I strongly suggest you make sure that it
>checks the return value of close().

The same comment, actually, is much more broadly applicable.  It's not
at all inconceivable for devices that use the buffer cache to report an
error in asynchronous I/O by returning an error from close().  One should
always check the result from close().

The same goes, double, for fclose().  There it's even stronger, because
fclose() has a high probability of doing buffer flushes that involve
actual I/O.
-- 
NASA is into artificial        |     Henry Spencer at U of Toronto Zoology
stupidity.  - Jerry Pournelle  | uunet!attcan!utzoo!henry henry@zoo.toronto.edu