2002-07-18 16:24:30

by Sandy Harris

[permalink] [raw]
Subject: Re: close return value

"Richard B. Johnson" wrote:
>
> On 18 Jul 2002, Patrick J. LoPresti wrote:
>
> > Pete Zaitcev <[email protected]> writes:
> >
> > > The problem with errors from close() is that NOTHING SMART can be
> > > done by the application when it receives it.
> >
> > This is like saying "nothing smart" can be done when write() returns
> > ENOSPC. Such statements are either trivially true or blatantly false,
> > depending on what you mean by "smart".
> >
> > Failures happen. They can happen on write(), they can happen on
> > close(), and they can happen on any system call for which the API
> > allows it. There is no difference! Your application either deals
> > with them and is correct or fails to deal with them and is broken.
> >
> > If the API allows an error return, you *must* check for it, period.
> [SNIPPED..]
>
> Well no. Many procedures are called for effect. When is the last
> time you checked the return-value of printf() or puts()? If your
> code does this it's wasting CPU cycles.

There's a classic paper on this:
http://www.apocalypse.org/pub/u/paul/docs/canthappen.html