Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site houligan.UUCP Path: utzoo!linus!decvax!bellcore!petrus!sabre!zeta!epsilon!gamma!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!akguc!codas!peora!ucf-cs!novavax!houligan!daemon From: daemon@houligan.UUCP Newsgroups: net.unix-wizards Subject: Re: Printf sets errno to 25? Message-ID: <238@houligan.UUCP> Date: Thu, 19-Dec-85 16:07:24 EST Article-I.D.: houligan.238 Posted: Thu Dec 19 16:07:24 1985 Date-Received: Sat, 28-Dec-85 23:36:36 EST Sender: daemon@houligan.UUCP Organization: Gould Electronics, Ft. Lauderdale, Florida. Lines: 35 In article <119@cpsc6a.UUCP>, peo@cpsc6a.UUCP (Paul E. Olson) writes: > 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? Once again, this discussion rears its ugly head. Check your manual page "INTRO(2)" for how "errno" is to be used. Specifically the phrase: "... errno should be tested ONLY after an error has occurred ..." (emphasis added). Please note that the value of "errno" upon return from a library routine is specifically UNDEFINED unless: 1. The documentation for the routine specifically states that an error code is returned in "errno" (this is untrue of the "printf" family), 2. The routine DOES NOT RETURN an error condition (a return of -1 in most cases). What this all boils down to is: Don't examine the value contained in "errno" UNLESS the called routine specifically indicated an error has occurred by its return value. --tgi while (--tgi) /* my mind continues to decay */ ; /* even though I do nothing.. */ {brl-bmd,ccvaxa,pur-ee,sun}!csd-gould!midas!tgi (Craig Strickland @ Gould) 305/587-2900 x5014 CompuServe: 76545,1007 Source: BDQ615 MCIMail: 272-3350 (echo ".ft B"; echo ".ps 999"; echo "$disclaimer") | troff -t # :-)