redirecting output

Karl Heuer karl at haddock.ima.isc.com
Wed Jul 4 04:28:53 AEST 1990


In article <JID4B=4 at ficc.ferranti.com> peter at ficc.ferranti.com (Peter da Silva) writes:
>While picking nits, how about doing it right. There's really no excuse for
>not calling perror:

Technically, there is.  The polite action is to set errno iff an error
occurs, but most non-syscall functions are not guaranteed to be polite.  In
particular, many implementations of fopen() can fail without setting errno (by
running out of buffers); conversely, an internal call to isatty() may have set
errno when no error has really occurred.

Some people maintain that, for this reason, one should not use perror() under
the circumstances we're talking about.  I disagree; even though errno is badly
botched, it's reasonable to use it until something better comes along.  (And I
use a version of isatty() that leaves errno alone.)

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.lang.c mailing list