checking close's return value

Henry Spencer henry at utzoo.uucp
Wed Sep 21 09:01:50 AEST 1988


In article <20981 at watmath.waterloo.edu> rbutterworth at 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 at zoo.toronto.edu



More information about the Comp.unix.wizards mailing list