Testing I/O success (Was: Portable Self-Replicating C Contest)

Karl Heuer karl at haddock.ima.isc.com
Wed Apr 19 11:11:48 AEST 1989


In article <25114 at watmath.waterloo.edu> rbutterworth (Ray Butterworth) writes:
|In article <8019 at boring.cwi.nl>, siebren at cwi.nl (Siebren van der Zee) writes:
|>In article <12593 at haddock.ima.isc.com> karl at haddock (Karl Heuer) writes:
|>>Note rule 3.  Output calls can fail (e.g. disk full); the program must
|>>detect this condition and return the value EXIT_FAILURE ...
|>
|>[Can't be done, in general.]  As far as the contest (and _ANY_ serious
|>program) is concerned, you still have to check whatever you can, of course.
|
|... Anyway, that means that in any program where you would like to be as sure
|as you can that it really does exit correctly, you must explicitly fclose all
|your stdio output streams, being sure to check the fclose() return status.

I ran into this issue as I was drawing up the rules, and I decided that, for
the purposes of this contest, the rule is satisfied if the program checks all
of its own I/O calls.  You needn't worry about the potential failure of the
implicit fflush()/fclose() in exit().

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
(If mail doesn't seem to be getting through, post a note to soc.net-people.)



More information about the Comp.std.c mailing list