Path: utzoo!attcan!uunet!cs.utexas.edu!usc!apple!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: redirecting output Message-ID: <17015@haddock.ima.isc.com> Date: 3 Jul 90 18:28:53 GMT References: <22931@dartvax.Dartmouth.EDU> <1990Jun29.172429.2818@zoo.toronto.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 16 Supersedes: <17008@haddock.ima.isc.com> In article peter@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@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint