Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

From: Terry Lambert <tlambert2_at_mindspring.com>
Date: Tue, 25 Nov 2003 18:21:13 -0800
Stefan Farfeleder wrote:
> On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote:
> > From: "Jacques A. Vidrine" <nectar_at_FreeBSD.org>
> > > The application is broken.  You must only check errno if you get an
> > > error indication from the library call.
> >
> > errno is only meaningful after a syscall error.
> 
> Wrong, counter-example: strtol().

Wrong; the standard specifies that the errno shall only be
checked when the return value is -1.  The exception in the
strtol() case is only for presetting errno to 0 before you
make the call, and making a check only following a -1 return.

You cannot make assumptions about underlying implementations;
they may be either system calls or library routines, and your
application is not supposed to know or depend on which case
prevails.

-- Terry
Received on Tue Nov 25 2003 - 17:53:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:31 UTC