lint question

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Jan 19 04:39:46 AEST 1989


In article <15024 at cisunx.UUCP> jcbst3 at unix.cis.pittsburgh.edu (James C. Benz) writes:
>Okay, so where does one find out what error codes are returned from these
>stdio functions?  The UNIX (AT&T 3B2) manuals I have say nothing in printf(3S)
>about error codes, and stdio(3S) says "Individual function descriptions 
>describe the possible error conditions"  Sounds like Catch 22 to me.

I don't know what you mean by "error codes".  The printf(3S) description
in the SVR3.0 PRM clearly states that the *printf() functions return the
number of characters transmitted, or a negative number in case of error.
(Happens that the negative number is -1, but you're not supposed to know
that.)  As with all UNIX system service-related operations, if some
system call failed, the extern int "errno" is set to hold one of the
error numbers described in the introduction to section 2 of the manual.
However, library functions such as printf(3S) can fail for reasons other
than system call failure, and even a successful printf(3S) may have
generated a system call failure on the way (typically a failed ioctl(2)
invocation to determine whether the stream is associated with a terminal),
so it is unwise to rely on the contents of errno to tell you anything
meaningful about the causes of printf(3S) errors.  Just consider them
"mysterious failures" and take appropriate recovery steps.



More information about the Comp.lang.c mailing list