Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site iclbra.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cornell!bullwinkle!rochester!seismo!mcvax!ukc!stc!iclbra!apm From: apm@iclbra.UUCP (Andy Merritt) Newsgroups: net.unix-wizards Subject: Re: Printf sets errno to 25? Message-ID: <212@iclbra.UUCP> Date: Tue, 17-Dec-85 13:29:13 EST Article-I.D.: iclbra.212 Posted: Tue Dec 17 13:29:13 1985 Date-Received: Sat, 21-Dec-85 06:23:27 EST References: <119@cpsc6a.UUCP> Distribution: net Organization: I.C.L., Lovelace Road, Bracknell, Berkshire. Lines: 21 Xpath: stc stc-a > *** 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 The problem is a common misunderstanding about the use of errno. The value in errno is useful if, and only if, the call has returned a value indicating failure. This value is commonly -1, and sometimes NULL for functions returning pointers. The Intro(2) manual page says: "Errno is not cleared on successful calls, so it should be tested only after an error has been indicated" The documentation I have for printf further states that it, fprintf and sprintf return the number of characters transmitted, or a negative value if an output error was encountered. Hope this helps. UUCP: ...seismo!mcvax!ukc!stc!iclbra!apm MAIL: Andrew Merritt, ICL, Lovelace Rd, Bracknell, Berkshire