Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site cpsc6a.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!akguc!cpsc53!cpsc6a!peo From: peo@cpsc6a.UUCP (Paul E. Olson) Newsgroups: net.unix-wizards Subject: Printf sets errno to 25? Message-ID: <119@cpsc6a.UUCP> Date: Thu, 12-Dec-85 14:55:33 EST Article-I.D.: cpsc6a.119 Posted: Thu Dec 12 14:55:33 1985 Date-Received: Sat, 14-Dec-85 08:08:59 EST Distribution: net Organization: AT&T Information Systems (CPSC), Oakland, CA Lines: 42 *** REPLACE THIS LINE WITH YOUR MESSAGE *** Could someone please explain to me why the printf() family of functions cause errno to be set to 25 (not a typewritter) when output is redirected to either a file or a pipe. I know that the problem comes from the C lib function isatty() when ioctl() fails. So, maybe the real question should be - Is this an oversight? It would seem to me that redirecting printf output does not constitute an error and that the functions _findbuf() and setbuf() should take care to reset errno to 0 if line buffering is not needed. At first I thought it was a bug, but now I'm not so sure. I get the same results using: SYS 5.0.5 on a 3B20 SYS 5.2 on a 3B5 SYS 5.2 on a 3B2 Xenix 3.0 on an Altos 4.2BSD on an 11/780 AT&T PC7300 The following illustrates the problem. /* foo.c */ extern int errno; main() { printf("errno=%d\n", errno); printf("errno=%d\n", errno); } $ cc foo.c -o foo $ foo errno=0 errno=0 $ foo >bar $ cat bar errno=0 errno=25 $ All this started while chasing a bug is some software I was porting. Thanks in advance for any and all comments. Paul E. Olson ihnp4!cpsc6a!peo