Newsgroups: comp.unix.programmer
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news
From: scs@adam.mit.edu (Steve Summit)
Subject: Re: sscanf always generates error condition
Message-ID: <1991May9.034302.21121@athena.mit.edu>
Sender: news@athena.mit.edu (News system)
Reply-To: scs@adam.mit.edu
Organization: Thermal Technologies, Cambridge, MA
References: <1991May1.024357.7750@dg-rtp.dg.com> <1991May7.020259.3646@athena.mit.edu> <1474@ecicrl.ocunix.on.ca>
Distribution: usa
Date: Thu, 9 May 91 03:43:02 GMT
Lines: 38

In article <1474@ecicrl.ocunix.on.ca> clewis@ferret.ocunix.on.ca (Chris Lewis) writes:
>In article <1991May7.020259.3646@athena.mit.edu> scs@adam.mit.edu writes:
>>(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.

It's hard to word correctly.  I had revised it several times, and
it still wasn't perfect.  It can't just say "system call,"
however, because a few library routines (e.g. many of the math
routines) *are* documented as setting errno.  There are also
non-Unix systems which have emulators for Unix system calls
present in the C library.  Finally, since system calls themselves
are invariably accessed through tiny routines also present in
"the library" (i.e. /lib/libc.a), I cheated and talked about
"library routine[s] that set errno on error."  I would not have
been so cavalier in a Unix FAQ list.

>(The more common guise under which this issue comes up
>>is "Why does errno contain ENOTTY after a call to printf?")
>
>Put the way this usually crops up: "Why did your sendmail bounce
>my mail with a:
>	550 ... Not a tty
>message" ;-)

Indeed.  (I'd forgotten the "real" question; thanks for the
reminder.)

                                            Steve Summit
                                            scs@adam.mit.edu
