sscanf always generates error condition

Chris Lewis clewis at ferret.ocunix.on.ca
Tue May 7 23:41:10 AEST 1991


In article <1991May7.020259.3646 at athena.mit.edu> scs at adam.mit.edu writes:

>As has been (correctly) pointed out, however, it's not incorrect
>for ISC's sscanf to be leaving EBADF in errno, because (to quote
>from an old version of the comp.lang.c frequently-asked questions
>list), "it is only meaningful for a program to inspect the
>contents of errno after an error has occurred (that is, after a
>library function that sets errno on error has returned an error
 ^^^^^^^^^^^^^^^^
>code)."

The underlined phrase should be "system call".  Library routines
can return an error yet the errno won't indicate the real reason
for the failure.  Most modern versions of the manual pages document
exactly which system calls set the errno, and describe the causes
for each one.  Ie: "errno is only relevant when a system call that
is documented to set errno indicates an error has occured by its
return value".

(The more common guise under which this issue comes up
>is "Why does errno contain ENOTTY after a call to printf?")

>                                            Steve Summit
>                                            scs at adam.mit.edu

Put the way this usually crops up: "Why did your sendmail bounce
my mail with a:
	550 ... Not a tty
message" ;-)
-- 
Chris Lewis, Phone: (613) 832-0541, Domain: clewis at ferret.ocunix.on.ca
UUCP: ...!cunews!latour!ecicrl!clewis; Ferret Mailing List:
ferret-request at eci386; Psroff (not Adobe Transcript) enquiries:
psroff-request at eci386 or Canada 416-832-0541.  Psroff 3.0 in c.s.u soon!



More information about the Comp.unix.programmer mailing list